Last post Aug 14, 2020 11:54 AM by PatriceSc
Aug 14, 2020 11:03 AM|jagjit saini|LINK
In below code i am getting above error
DECLARE @path NVARCHAR(256) -- path for backup files
DECLARE @fileName NVARCHAR(256) -- filename for backup
DECLARE @fileDate NVARCHAR(20) -- used for file name
-- specify database backup directory
SET @path = 'c:\Backup\'
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE Test TO DISK = @fileName
Aug 14, 2020 11:54 AM|PatriceSc|LINK
I suspect @name (not even declared, you didn't show this part of the code?) could be NULL causing @filename to be NULL which seems to match an error message such as an "invalid zero length device name".
Don't just read the code but also see what it does especially here as it seems the only problem could be the value stored in @filename.