• nkm129 (4/30/2008)


    This is showing error

    Incorrect syntax near '+'.

    You will need something like this:

    [font="Courier New"]declare @BakFile char(50)

    set @BakFile = 'S:\SqlBackups\DbName '+convert(char(8),getdate(),112)+'.bak'

    backup database DbName to disk = @BakFile[/font]

    Again, this will append Year-Month-Day, but you will need to do additional work to clear out the colons if you are looking to add hours-minutes, as you would for a log backup that occurs more than once a day. Check out Books Online (BOL) for syntax of CONVERT for datetime types.

    Mike Hinds Lead Database Administrator1st Source BankMCP, MCTS