[unixODBC-support] Newbie question - how to execute a stored proc

Nick Gorham nick at lurcher.org
Tue Mar 5 16:39:50 GMT 2013


On 05/03/13 16:25, John Bradley wrote:
>
> I have a completely newbie question for the list. I've looked through 
> a few years' worth of archives but can't find it addressed anywhere 
> previously and Google isn't helping me at all. I've installed and 
> started using unixODBC and am working on a Linux c shell script that 
> uses ISQL from the command line to run some queries in my MSSQL 2008 
> DB. Everything works fine, except I can't figure out how to get it to 
> run a stored procedure.
>
> An example of something that works:
>
> variable=`echo select column from schema.table where column=thing|isql 
> dbname userid password -b -x0x20`
>
> This populates variable and everything works. I figured I'd be able to 
> do the same thing with an sp:
>
> `echo exec schema.procname @parm=value|isql dbname userid password -b 
> -x0x20`
>
> But all I get in return is "[ISQL]ERROR: Could not SQLExecute". I've 
> tried every permutation of all caps, mixed case, wrapping things in 
> brackets and just doing it from the ISQL command line and I never get 
> anything but "[ISQL]ERROR: Could not SQLExecute". I know it's 
> something obvious, but I can't figure it out. Can anyone help me?
>
> Thanks,
>
> John
>

It may depend on the driver you are using. I think what you are doing 
should work, this is with our (Easysoft) SQLServer driver

echo "exec sp_columns @table_name=fred" | isql -b -x0x20  -v sqlsrv2008 
test test
AdventureWorks dbo fred i 4 int 10 4 0 10 1   4   1 YES 38
AdventureWorks dbo fred c 1 char 200 200   1   1  200 2 YES 39

So in theory what you are trying should work.

-- 
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20130305/0330dfb9/attachment.html>


More information about the unixODBC-support mailing list