I'm using the below to backup a db from a SQL job. Can someone tell me how to add the current date to the output filename? Preferably in YYYYMMDD format.
BACKUP DATABASE [myDB] TO? DISK = N'\myPathmyDB.bak' WITH NOFORMAT, INIT,? NAME = N'myDB', SKIP, REWIND, NOUNLOAD,? STATS = 10 GO
Thanks!
DECLARE @MyFileName varchar(1000) SELECT @MyFileName = (SELECT '\ServerToSavePathMyDB_' + convert(varchar(500),GetDate(),112) + '.bak') BACKUP DATABASE [myDB] TO DISK=@MyFileName ...
2.1m questions
2.1m answers
60 comments
56.9k users