F
F
Fisher2018-09-07 21:26:30
SQL Server
Fisher, 2018-09-07 21:26:30

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

only the date is added to the file name, although the time should be, but it is not. What is the problem here?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question