Take the 2-minute tour ×
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
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.