Home Forums SQL Server 7,2000 T-SQL Adding date timestamp to a backup file name RE: Adding date timestamp to a backup file name

  • Or, if you want to remove the dashes as well:

    DECLARE @BackupFileName varchar(100)

    SET @BackupFileName = 'C:\temp\TestDB_' + REPLACE(REPLACE(REPLACE(CONVERT(varchar,GETDATE(), 20),'-',''),':',''),' ','') + '.BAK'

    BACKUP DATABASE TestDB

    TO <A href="mailtoISK=@BackupFileName">DISK=@BackupFileName

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden