On 9/18/08, Dan Joseph <dmjoseph@xxxxxxxxx> wrote: > Hi, > > Anyone else using the odbc_* functions to interact with MS SQL Server 2005? > > I'm having a problem getting odbc_num_rows() to return anything other than > -1 when querying a stored procedure. I can get it to work using Top in a > normal query (non-stored procedure). > > SELECT Top 1000000 * FROM Table > > if I do an odbc_num_rows( result ) on that, I get the number of rows. > However... > > EXEC ProcedureName @Var = 'value' > > if I do an odbc_num_rows( result), I get -1. The same is true if I did a > straight SELECT * FROM Table. I've tried putting Top in my query in the > stored procedure. > > Right now I'm either doing an extra query for @@ROWCOUNT, or I'm doing two > result sets, a counting query, and then the normal query. I am concerned > about performance in doing the two queries, and with @@ROWCOUNT, I feel I'm > just adding extra things to the code that may be unreliable? > > From what I've read, its something with the ODBC driver, and updating the > ODBC driver isn't an option. > > Anyone else having this problem? Any suggestions? > > -- > -Dan Joseph Dan, If you already have your results in an array, try using count($result); That should count the number of results returned to your result array. Or you could try uncommenting the mssql extension in your php.ini file and then try using: mssql_num_rows() ? Dan