backup job adding timestamp to generated file

  • Hi:

    i need to add timestamp to automatic generated backup files, these are full database backups, using jobs from management SQL server agent.

    The idea is to archive this backups that i set to be maiden once a day, and identified them from the timestamp (date).

    Thanks a lot


  • Declare @Dt_DateAndTime Varchar(30), @dbname sysname, @file sysname

    select @Dt_DateAndTime = convert(char(8), getdate(), 112)+''+ Replace(convert(char(12), getdate(), 14),':','')

    select @dbname = 'master'

    select @file = 'c:\'+@dbname+'_'+@Dt_DateAndTime

    select @file

    backup database @dbname to disk =  @file

    with init

    Microsoft SQL Server MVP

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

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