Over a million developers have joined DZone.

Backup Database With Date Timestap In Filename

·
// 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
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}