Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
geauga
Starting Member
5 Posts |
Posted - 2007-09-24 : 11:15:39
|
I am trying to run a SQLCMD command from within a batch file. THe line that I am running is:sqlcmd -S 10.90.228.52 -E –d outpatient –iC:\Data\CASS_Billing.sql -o c:\data\CASS_Output.txtI get an error : Unexpected argumentIt seems like the "-" in front of the parameters are not being interpreted correctly yet if I run the command at a command line manually it works fine. Any suggestions?-Rick- |
|
Kristen
Test
22859 Posts |
Posted - 2007-09-24 : 11:20:38
|
If SQLCMD on the "path" when it is run from within the Batch file?Might be that the Path for your "direct" session is different?Perhaps add:PATH > C:\JUNK_PATH.$$$to the front of your batch file so you can review that the appropriate folder is in there (/program files/.../SQL/.../BINN something-or-other!!)You could also, temporarily, change the line that executes SQLCMD to prefix it with ECHO and append >C:\JUNK_CMD.$$$ thus:ECHO sqlcmd -S ... -o c:\data\CASS_Output.txt >C:\JUNK_CMD.$$$so that you can see exactly what command string was attempted.KristenKristen |
|
|
geauga
Starting Member
5 Posts |
Posted - 2007-09-24 : 11:49:17
|
When I ECHO the command it is the correct command displayed. It is somethiong to do with the minus signs required in from of the parameters.-Rick- |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-24 : 11:59:59
|
"It is somethiong to do with the minus signs required in from of the parameters."FWIW I have never know that be a problem with a Batch file.I presume the echo'd PATH was OK too?Kristen |
|
|
geauga
Starting Member
5 Posts |
Posted - 2007-09-24 : 15:14:16
|
The ECHO'ed path was fine. What I see happen is that if I include only a single parameter everything is fine but once I add a second parameter I get the error "Unexpected argument" and the second and subsequent minus signs are changed to be ^U.-Rick- |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-25 : 02:12:34
|
Bizarre. I presume the command is EXACTLY how you showed it above, and it doesn't have any additional punctuation characters such as & - which is used to split a command into two parts?Does SQLCMD allow the use of "/" instead of "-" to define the attributes?Kristen |
|
|
geauga
Starting Member
5 Posts |
Posted - 2007-09-25 : 10:26:53
|
On the SQLCMD help screen it only shows the '-' as a delimiter. What is so frustrating this that thhe exact command works when typed on a command line. I have found very few examples in web searches of people using batch files to run SQLCMD commands but the few I see have parameters and I assume that they work.-Rick- |
|
|
geauga
Starting Member
5 Posts |
Posted - 2007-09-25 : 10:39:10
|
Whereas the help does not document "/" as a valid delimeter. When I tried, it worked. Thanks for the help.-Rick- |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-26 : 05:10:12
|
I still think its Bizarre but glad that "/" worked for you. |
|
|
|
|
|