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:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}