none
Terminate previous threads in the session

    Question

  • Hi Every body.
    I need to know if can I terminate all previous threads in the session while I'm working with SQL Server or no?
    I have a transaction call that don't run anymore because it seems that a previous thread is still open in the session.

    How can I terminate all previous open threads ?

    Saturday, March 10, 2012 9:23 AM

Answers

  • An SQL statement is considered closed when you have consumed all the results or closed the statement.  Here is an example that both consumes the results and closes the statement.

    $conn = sqlsrv_connect($server, $options);
    
    if ( ($stmt = sqlsrv_query($conn, $statement)) )
    {
        do 
        {
            $rows += sqlsrv_rows_affected($stmt);
            // other statements
        } while ( sqlsrv_next_result($stmt) ) ;
        sqlsrv_free_stmt($stmt);
    }


    Rob

    Saturday, March 10, 2012 8:06 PM