SQL Server stored procedure output parameters.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm having difficulty getting the value of output parameters from stored
procedures on a SQL server.
I understand that this just doesn't work with odbc so I've tried both the
mssql functions route, and the PDO route. In both instances I can execute the
query and iterate over the result set, but in both cases the variable bound to
the output parameter isn't having it's value changed.

In my searches online I've come across examples of how it 'should' work, and
plenty of posts of people unable to get it to work. Is there something special
that needs to be done to have it set?

The bind calls I'm trying are (mssql and PDO respectively)
mssql_bind($stmt, '@Output', $output, SQLINT4, true);
$stmt->bindParam(2, $OutPut, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT, 16);

I'm hoping someone can maybe shed some light on this, or at least point me in
a direction which has eluded me thus far.


Re: SQL Server stored procedure output parameters.

David Gillen schreef:
Quoted text here. Click to load it

Hi David,

This might help a little:
http://blog.stuartherbert.com/php/2007/10/16/microsofts-first-php-extension-sql-server-2005-support /

The lower section named:
What’s Wrong With The Existing MSSQL Extension For PHP?

Also, M$ is making a new driver, read more here:

Maybe it helps using their new version.
I am NOT sure because I didn't try it yet, but read some good reviews.
If that is an option for you: Give it a shot

Please report back here with your experiences.

Regards and good luck,
Erwin Moller

Re: SQL Server stored procedure output parameters.

On Thu, 27 Mar 2008 Erwin Moller wrote:
Quoted text here. Click to load it


Quoted text here. Click to load it
http://blog.stuartherbert.com/php/2007/10/16/microsofts-first-php-extension-sql-server-2005-support /
Quoted text here. Click to load it
Hi Erwin,
Thanks for the response. Was just checking here to post progress.
Using the SqlCommand class from the URL below I've managed to very quickly get
the results back and the output parameters working. It depends on the pear DB
library, which while deprecated in favour of MDB2 is doing the job.
I'd recommend this for anyone trying to get output parameters to work with

Unfortunately in this instance my access to the servers is very limited so
it's unlikely I'll be able to get that new driver installed, however I've book
marked it and will likely try it out in the near future.


Site Timeline