tags:

views:

198

answers:

3

I have foo.sql as:

print 'foo=$(foo)'

Then I have in foo.cmd the following shell script:

sqlcmd -i foo.sql -v foo="c:\path"

Running foo.cmd prints:

foo=\path

how do I escape the "c:"? Is dos-shell eating it, or is it sqlcmd?

A: 

Escape the backslash,

sqlcmd -i foo.sql -v foo="c:\\path"

It's actually your shell eating the \

Richo
`cmd` doesn't even use `\\` as the escape character. How do you think it's supposed to interpret it as such?
Joey
+1  A: 

cmd's argument delimiters include the equal sign. I've seen in other cases (such as bjam.exe) that the entire parameter sequence has to be quoted to work properly.

Try this:

sqlcmd -i foo.sql -v "foo=c:\path"

If it still strips the "c:" portion, I'd focus on sqlcmd. I don't personally have it installed to test with. This is based solely on experience with similar situations.

thom.crane
A: 

OK, my mistake. the above does work.

What i did wrong was doing: sqlcmd -i foo.sql -v foo='c:\path'

(single quote, since I tried to pass them as ' ' sql string) that won't work. it will chop the c:

Xerion