Red Gate forums :: View topic - Command Prompt Snapshot with Space in DB Name ?
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Compare Previous Versions
SQL Compare Previous Versions forum

Command Prompt Snapshot with Space in DB Name ?

Search in SQL Compare Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
ryanofford



Joined: 15 Dec 2010
Posts: 3
Location: Manchester

PostPosted: Wed Dec 15, 2010 11:39 am    Post subject: Command Prompt Snapshot with Space in DB Name ? Reply with quote

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
View user's profile Send private message
ryanofford



Joined: 15 Dec 2010
Posts: 3
Location: Manchester

PostPosted: Wed Dec 15, 2010 11:44 am    Post subject: Reply with quote

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
View user's profile Send private message
james.billings



Joined: 16 Jun 2010
Posts: 1120
Location: My desk.

PostPosted: Wed Dec 15, 2010 6:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic 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