| Author |
Message |
fredmut
Joined: 21 Jun 2012 Posts: 5
|
Posted: Thu Jun 21, 2012 10:05 pm Post subject: Backup databases whose names includes spaces |
|
|
| 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. |
|
| Back to top |
|
 |
Marianne
Joined: 03 Oct 2011 Posts: 45
|
Posted: Fri Jun 22, 2012 9:45 am Post subject: |
|
|
Hi,
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):
| Code: |
| execute master..sqlbackup '-sql "BACKUP DATABASE [database name] TO DISK = ''C:\Backups\<AUTO>.sqb'' WITH CHECKSUM, THREADCOUNT = 3" ' |
(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 _________________ Marianne Crowder
SQL Backup 7 Team
Red Gate Software Limited |
|
| Back to top |
|
 |
fredmut
Joined: 21 Jun 2012 Posts: 5
|
Posted: Fri Jun 22, 2012 2:08 pm Post subject: |
|
|
| Thanks Marianne. I'll give that a try. One more question - can I pass in a TSQL like variable for the database name so I don't have to maintain a hard coded list of databases to backup or exclude? I'm not finding that addressed in the documentation. |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group