DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Backup Database With Date Timestap In Filename

01.29.2007
| 239 views |
  • submit to reddit
        // SQL Server 2005 
DECLARE @filename nvarchar(128)
SET @filename=N'C:\Backup\master' + '_' +convert(varchar(8), getdate(), 112) + '_' + replace(convert(varchar(8), getdate(), 108), ':', '') + '.bak'
BACKUP DATABASE [master] TO DISK = @filename WITH NOINIT , NOUNLOAD , NAME = N'master backup', SKIP , STATS = 10, DESCRIPTION = N'master System Backup', NOFORMAT