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.
BACK
Try this.
DECLARE @MyFileName varchar(50) SELECT '\\ServerToSave\Path\MyDB_' + convert(nvarchar(20),GetDate(),112) + '.bak' BACKUP DATABASE [myDB] TO DISK=@MyFileName ...
The 112 in the Convert gives you the YYYYMMDD format