What are the challenges you face when working across database platforms? Take the survey
Options

Command Prompt Snapshot with Space in DB Name ?

ryanoffordryanofford Posts: 5
edited December 15, 2010 12:18PM in SQL Compare Previous Versions
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

Comments

  • Options
    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'
  • Options
    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.
    Systems Software Engineer

    Redgate Software

Sign In or Register to comment.