Sript Name with Current Date

  • How to name a string with the current date??Please help

    BACKUP DATABASE [CollSoftware2]

    TO  DISK = N'C:\01_01_2006.bck' WITH  INIT , NOUNLOAD , Name = N'CollSoftware2',  NOSKIP ,  STATS = 10,  NOFORMAT

  • The ISO date format is probably best for this; so something like:

    DECLARE @DiskStr NVARCHAR(255)

    SET @DiskStr = N'C:\CollSoftware2_' + CONVERT(NVARCHAR(8), GETDATE(), 112) + N'.bak'

    BACKUP DATABASE [CollSoftware2]

    TO  DISK = @DiskStr

    WITH  INIT , NOUNLOAD , Name = N'CollSoftware2',  NOSKIP ,  STATS = 10,  NOFORMAT

Viewing 2 posts - 1 through 1 (of 1 total)

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