Answer the question
In order to leave comments, you need to log in
How to add date to SQL database backup name?
Hey!
With this method:
DECLARE @filename varchar(255)
SET @filename = 'D:\Backup\DB_hourly_' + REPLACE(convert(char(19),GetDate(),120),':','-') + '.bak'
BACKUP DATABASE [db] TO [email protected] WITH RETAINDAYS = 7, NOFORMAT, INIT, NAME = N'db-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question