Command Prompt Snapshot with Space in DB Name ?

Forum for users of SQL Compare schema synchronization utility

Moderators: JonathanWatts, Chris Auckland, David Atkinson

Command Prompt Snapshot with Space in DB Name ?

Postby ryanofford » Wed Dec 15, 2010 11:39 am

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
ryanofford
 
Posts: 3
Joined: Wed Dec 15, 2010 11:24 am
Location: Manchester

Postby ryanofford » Wed Dec 15, 2010 11:44 am

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'
ryanofford
 
Posts: 3
Joined: Wed Dec 15, 2010 11:24 am
Location: Manchester

Postby james.billings » Wed Dec 15, 2010 6:18 pm

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.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.


Return to SQL Compare Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests