I also dont understand why you cant return the rowcount as a column when using a stored procedure as opposed to just us For large result sets the stored procedure execution will not continue to the next statement until the result set has been completely sent to the client. I need to pass this back to my application for the progress bar to function correctly. The procedure is then called in a batch. As with OUTPUT parameters, you must save the return code in a variable when the procedure is executed in order to use the return code value in the calling program. For a forward-only cursor, if the cursor is positioned beyond the end of the last row when the procedure exits, an empty result set is returned to the calling batch, procedure, or trigger. EXECUTE statements preserve the previous @@ROWCOUNT. No error is returned, but you cannot use the output value in the calling program. RETURN Default.aspx code I tried: By issuing a SET NOCOUNT ON this function (@@ROWCOUNT) still works and can still be used in your stored procedures to identify how many rows were affected by the statement. For a scrollable cursor, all the rows in the result set are returned to the calling batch, procedure, or trigger when the procedure exits. Nelle stored procedure compilate in modo nativo viene mantenuto il valore @@ROWCOUNT precedente. Normally you would combine the RETURN statement with an IF statement in order to return different values based on a condition, such as in the example shown below:In the example above our stored procedure attempts to retrieve records from a table based on the value of a parameter. Paul, Thanks for the link, it says the same thing "When you use a DataReader object, you must close it or read to the end of the data before you can view the output parameters.". You can use the @@ERROR function after a Transact-SQL statement to detect whether an error occurred during the execution of the statement. The following example shows a stored procedure that returns the LastName and SalesYTD values for all SalesPerson rows that also appear in the vEmployee view. The new value would be passed back out of the procedure through the OUTPUT parameter, updating the value in the @SalesYTDBySalesPerson variable when the procedure exits. To save the value of the parameter in a variable that can be used in the calling program, the calling program must use the OUTPUT keyword when executing the procedure. In a few lines, we’re able to count the results from a stored procedure as well as suppressing its return. select * from student. Within the procedure, we are using the COUNT to find the number of employees in the Employee Duplicate table, and then we are returning the value. PDOStatement::rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding PDOStatement object. That is, you capture @@rowcount inside the dynamic SQL and return it in an output parameter. Le istruzioni di tipo USE, SET