August 26, 2016 at 5:46 am
I need some help to remove the spaces from my backup job...
Its outputting as:
"dbname_DD MMM YYYY.bak"
But I would like:
"dbname_DDMMMYYYY.bak"
Heres my T-SQL...
USE dbname
DECLARE @dbname varchar(200)
SELECT @dbname='filepath\dbname_' + REPLACE(convert(varchar(20),GetDate(),106),':','-') + '.bak'
BACKUP DATABASE [dbname] TO DISK=@dbname with compression
Thanks
August 26, 2016 at 7:11 am
You have the wrong characters in your REPLACE function. Use the correct ones and you should get it done.
August 26, 2016 at 7:17 am
August 26, 2016 at 7:31 am
Thanks both, I'm using "REPLACE(convert(varchar(20),GetDate(),106),' ','') + '.bak'" which has done the trick!
August 26, 2016 at 8:09 am
J2B (8/26/2016)
I need some help to remove the spaces from my backup job...Its outputting as:
"dbname_DD MMM YYYY.bak"
But I would like:
"dbname_DDMMMYYYY.bak"
Heres my T-SQL...
USE dbname
DECLARE @dbname varchar(200)
SELECT @dbname='filepath\dbname_' + REPLACE(convert(varchar(20),GetDate(),106),':','-') + '.bak'
BACKUP DATABASE [dbname] TO DISK=@dbname with compression
Thanks
Just as an "ease of maintenance" and "ease of discovery" for your backup file names, you should store the files with sortable names AND a time when the backup started in the form of dbName_YYYYMMDD_HHMISS. This is especially true when it comes to taking dozens of log file backups each day.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply