DOS Command Switches - Use double quotes in switch arguments?

I've been banging my head against the wall for the last two hours with a bcp call for MSSQL.

bcp MyDB.dbo.MyTable in "C:\..." -S MyServer\MyInstance -T -f "C:\MyBCPFormatFile.xml"

On a whim, I added double quotes to the argument associated with the server switch, and it worked! (Note the quotes around MyServer\MyInstance.)

bcp MyDB.dbo.MyTable in "C:\..." -S "MyServer\MyInstance" -T -f "C:\MyBCPFormatFile.xml"

Is it safe to always wrap the arguments associated with a switch (option) with double-quotes?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Trenton KnewOwner / Computer WhispererCommented:
Typically, you only need to fool with the quotes if your argument contains a space.  so C:\Users\Joe\Documents wouldn't need a quote, whereas "C:\Users\Joe\Documents\Float Trip" would.

there is also a difference, however between using single quotes vs double quotes.  Did any of your arguments originally contain a space?
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Sadly, each program can handle double quotes (and other quotes) as they like. In a cmd shell or batch it should be safe, however, to always use double quotes, There are exceptions. So: it depends.

You should not need to use double quotes for the server\instance in bcp, as you don't with sqlcmd or isqlw etc.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jdanaAuthor Commented:
Thanks guys, Great feedback.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.