June 18, 2009 at 6:55 am
Hi,
I have old server and cannot move it around so want to run backups on it with script:
How can i make it to create new file everyday?
BACKUP DATABASE [test_DATA] TO DISK = N'T:\Program Files\Microsoft SQL Server\Backup\TRACKIT70'+ sysdate() +'.bak' WITH NOFORMAT, NOINIT, NAME = N'Test_DATA-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
June 18, 2009 at 7:37 am
i dont think sysdate() is a valid function (unless its a UDF).
try replacing that with convert(varchar, getdate(),112) and it should be fine.
btw, what is the question?
June 18, 2009 at 8:07 am
it says:
Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '+'.
June 18, 2009 at 8:12 am
try this.
declare @filename varchar(100)
set @filename='T:\Program Files\Microsoft SQL Server\Backup\TRACKIT70' + convert(varchar, getdate(),112) + '.bak'
BACKUP DATABASE [test] TO DISK = @filename WITH NOFORMAT, NOINIT, NAME = N'Test_DATA-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply