Backup databases whose names includes spaces
fredmut
Posts: 7
I need to backup a set of databases (via SQL Agent job) with names that include spaces (yes I know that's not best practice). I'm using a command like EXECUTE master..sqlbackup ''-SQL "BACKUP DATABASES [Bad Database Name].... but it doesn't parse. I've tried surrounding the name in double quotes and square brackets without success. Any help would be greately appreciated.
Comments
Thanks for your post. When using the extended stored procedure, the parameters must be surrounded by one set of single quotes, so any variables inside the command must be surrounded by two sets of single quotes (or square brackets). If your database name includes spaces, you should surround it with square brackets, rather than two pairs of single quotes. Your command should look like this (replacing variables and WITH options as required):
(The disk location is surrounded by two sets of single quotes, whereas the BACKUP command is surrounded by one set of double quotes. The entire parameter is surrounded by one set of single quotes.)
There is more information about using the extended stored procedure here: http://www.red-gate.com/supportcenter/Content/SQL_Backup/help/7.1/SBU_UsingStoredProc and examples of SQL Backup syntax here: http://www.red-gate.com/supportcenter/Content/SQL_Backup/help/7.1/SBU_Toolkit_syntax_egs
If this doesn't help, can you post the exact command you are using?
Thanks,
Marianne
Red Gate Software Limited