-
Syntax for osql for executing sp with parameters.
Can anyone tell me syntax for executing a stored procedure using osql which accepts 4 input parameters which are char data types?
I am getting syntax errors all the time..
-
I believe it should be this:
osql -Uuserid -Ppassword -Sservername -ddatabase -Q"execute storedprocedure 'parameter1', 'parameter2', 'parameter3', 'parameter4'"
-
osql -U userid -P password -S servername -d database -Q "execute storedprocedure 'parameter1', 'parameter2', 'parameter3', 'parameter4'"
I think it wants a space
-
It will work the same with or without a space between the switch and the value.
-
Thanks, but I am still getting errors:
Here is the query:
EXECUTE master..xp_cmdshell 'osql -Sservername -ddbname -Q"exec p_procname '11/03/03','ABX','NPT','KB'" -E'
Here is the error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '11'.
Any idea?
-
EXECUTE master..xp_cmdshell 'osql -SServername -ddbname -Q"exec p_procname ''11/03/03'',''ABX'',''NPT'',''KB''" -E'
-
Thanks MAK, but still no luck here..gives me this output:
usage: osql [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w columnwidth]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-L list servers] [-c cmdend] [-D ODBC DSN name]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-n remove numbering] [-m errorlevel]
[-r msgs to stderr] [-V severitylevel]
[-i inputfile] [-o outputfile]
[-p print statistics] [-b On error batch abort]
[-X[1] disable commands [and exit with warning]]
[-O use Old ISQL behavior disables the following]
<EOF> batch processing
Auto console width scaling
Wide messages
default errorlevel is -1 vs 1
[-? show syntax summary]
NULL
(19 row(s) affected)
-
Did you try run that osql portion in dos prompt?
-
Just to make sure, when using MAK's syntax, did you use 2 consecutive single quotes instead of a double quote when applicable? There should be 2 consecutive single quotes around each parameter. There is a double quote after between -Q and exec, and a double quote before -E. I mean no offense if you indeed read MAK's syntax correctly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|