简体   繁体   中英

Sql Server, number of rows with stored procedures

I have a project, its written in php and running on sql server. They are using stored procedures. I noticed that when they want to get number of rows from a procedure, they used very slow method. Its going while() function and counting every row, then returning total number of count. Ex:

function numrow($procedure, $inputs) {
$callpro= callPro($procedure, $inputs);
while ($row = getrow($callpro)) {
$number++;
}
$numrows = $number;
return $numrows;
}

is there any way to speed this method ? i tried to use sqlsrv_num_rows, but its gives nothing on procedures.

There is a function called mssql_num_rows() which return the number of rows in a result set. So something like:

$numrows = mssql_num_rows($reslutSet)

should help. Note: The $resultSet has to be a result of the call mssql_query() . So my solution is dependand on how callPro() is implemented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM