SQl Backup

  • 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

  • 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?



    Pradeep Singh

  • it says:

    Msg 170, Level 15, State 1, Line 3

    Line 3: Incorrect syntax near '+'.

  • 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



    Pradeep Singh

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply