Command Line scripting with a space in the DB name

Larry IrvingLarry Irving Posts: 5
edited October 16, 2006 9:33AM in SQL Compare Previous Versions
First off, I'm a new user to the product and I think it's great. It will give us the daily schema compares we've been looking for (due to auditory regulations) for awhile now.

Anyway, what we have is a script that will run each night and create snapshots of our databases. The following works fine for us (called from a vbscript using the method):

cmd /C "C:\Program Files\Red Gate\SQL Bundle 5\SQLCompare.exe" /database1:db_name /makesnapshot:\\server\share\snapshots\db_name.snp

But we've also got some databases with a space in their name. When we try to run the command:

cmd /C "C:\Program Files\Red Gate\SQL Bundle 5\SQLCompare.exe" /database1:db name /makesnapshot:\\server\share\snapshots\db name.snp

The script fails because it's trying to connect to a database named db. Is there a "wrapper" I can use like [db name]?

We've tried various other options as far as quoting the parameters passed into the sqlcompare.exe program and either the cmd command fails or the /database: parameter only interprets the db name to the space.

Any ideas?



  • I figured it out.

    Instead of using:

    cmd /C "C:\Program Files\Red Gate\SQL Bundle 5\SQLCompare.exe" /database1:db name /makesnapshot:\\server\share

    I changed it to the old sytle path like this and I was able to use quotes around the parameters instead of the executable path:

    cmd /C c:\progra~1\redgat~1\sqlbun~1\SQLCompare.exe "/database1:dn name" /makesnapshot:\\server\share

    I also replace any spaces in the /makeshapshot: parameter with _, otherwise I probably would have needed quotes around that as well.

  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi Larry,

    Normally this would work. Perhaps if you are using an older OS like Windows NT, this could be necessary. Otherwise, it could be down to having 'command extensions' disabled in your cmd configuration.
This discussion has been closed.