How can I get the database backup name with timpstamp

  • backup database db1 to disk='d:\Backup\a_'SELECT GETDATE()'.bak';

    Thanks

  • Use Dynamic Query to do this.

    declare @dtbak varchar(50) = replace(replace(getdate(), ' ', ''), ':', ''), @sql varchar(1000)

    select @dtbak

    set @sql = 'backup database db1 to disk=''d:\Backup\a_'+ @dtbak + '.bak''';

    print @sql

    Abhijit - http://abhijitmore.wordpress.com

  • Dear Abhijit Thanks,

    I want the backed up database name with timestamp when backup command has run.

    Thanks

  • forsqlserver (6/29/2011)


    Dear Abhijit Thanks,

    I want the backed up database name with timestamp when backup command has run.

    Just try yourself with the help of sys.dataabses

    I hope you'll try.

    Muthukkumaran Kaliyamoorthy
    https://www.sqlserverblogforum.com/

  • muthukkumaran Kaliyamoorthy (6/29/2011)


    ...I hope you'll try.

    I strongly second that forsqlserver!

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Search backup in our scripts section. There are lots of examples that do exactly what you are looking for.

Viewing 6 posts - 1 through 5 (of 5 total)

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