| Author |
Message |
ryanofford
Joined: 15 Dec 2010 Posts: 3 Location: Manchester
|
Posted: Wed Dec 15, 2010 11:39 am Post subject: Command Prompt Snapshot with Space in DB Name ? |
|
|
I'm trying to run a batch file that takes a snapshot of each DB on my servers each day and it works well except when the database name has spaces in it. Virtually all of my DB's have no spacing in the names but I've 'inherited' a new one that I can't change the names on.
Basic version of the script follows :
Works
-------
CD\
SET FDate=%Date:~-10,10%
SET Fdate=%FDate:/=-%
MD C:\Snapshots\SERVERNAME
MD C:\Snapshots\SERVERNAME\%FDate%
DEL C:\Snapshots\SERVERNAME\%FDate%\*.* /Q
SQLCompare /Server1:SERVERNAME /Database1:DBNameWithoutSpaces /MakeSnapshot:"C:\Snapshots\SERVERNAME\%FDate%\FileNameHere.snp"
Fails
------
CD\
SET FDate=%Date:~-10,10%
SET Fdate=%FDate:/=-%
MD C:\Snapshots\SERVERNAME
MD C:\Snapshots\SERVERNAME\%FDate%
DEL C:\Snapshots\SERVERNAME\%FDate%\*.* /Q
SQLCompare /Server1:SERVERNAME /Database1:DB Name With Spaces /MakeSnapshot:"C:\Snapshots\SERVERNAME\%FDate%\FileNameHere.snp"
Running 8.50.12.20 Pro Edition
Any ideas anyone ?
Thanks
Ryan |
|
| Back to top |
|
 |
ryanofford
Joined: 15 Dec 2010 Posts: 3 Location: Manchester
|
Posted: Wed Dec 15, 2010 11:44 am Post subject: |
|
|
I should explain I get the error :
Error: Error occurred connecting to database: Cannot open database "xxxx" requested by the login. The login failed. Login failed for user 'xxxx' |
|
| Back to top |
|
 |
james.billings
Joined: 16 Jun 2010 Posts: 844 Location: My desk.
|
Posted: Wed Dec 15, 2010 6:18 pm Post subject: |
|
|
You should be able to get around this by enclosing the DB name with spaces in double quotes:
sqlcompare /db1:Adventureworks /db2:"Some Spaces"
The issue occurs because spaces separate the switches so without the quotes the database name is interpreted as just the part up to the first space and you get the error. |
|
| 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