Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
$sql = "SELECT  * FROM lastdeath";

$result = sqlsrv_query( $con, $sql);
if( $result === false )
 die( print_r( sqlsrv_errors(), true));

$row_count = sqlsrv_num_rows($result);
echo $row_count;

if ($row_count === false)
      echo "\nerror\n";

On this one i dont have cursor type set, however if id use

$result = sqlsrv_query( $con, $sql , array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));

or any other cursor type the whole script will time out in 30s.

and without, the num_rows returns False.

share|improve this question

closed as off-topic by Max Vernon, RolandoMySQLDBA, Mark Sinkinson, dezso, Colin 't Hart Jun 2 at 9:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Max Vernon, RolandoMySQLDBA, Mark Sinkinson, dezso, Colin 't Hart
If this question can be reworded to fit the rules in the help center, please edit the question.

I imagine this is tablescanning, but I'll let one of the SQL Server people confirm that. Use a COUNT(*) instead? –  Phil Aug 21 '12 at 21:37
i need it to return the number of rows that it selected . so when i use sqlsrv_fetch_array to write the results into arrays that i could use. then using the for loop to iterate through array and display results. but i Need the number of rows the query returned for the loop since its no t static number. –  Agony Aug 21 '12 at 21:43
Do you need to use the data or just get the rowcount? –  Phil Aug 21 '12 at 21:45
i need to use the data as well. –  Agony Aug 21 '12 at 21:49
Are you able to use stored procedures? –  Mr.Brownstone Aug 22 '12 at 7:09

Browse other questions tagged or ask your own question.