Display number of records effected by update/delete/insert SQL statement

5 pts.
Tags:
SQL
SQL statements
Whenever I carry out an insert/delete/update SQL statment I would like to show how many records have been effected in the Run History box. Sometimes this does work OK but not always. Need to know what if anything if is controlling the display of this information.

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you are running a stored procedure and it is not returning this information then when the procedure was written the SET NOCOUNT ON flag was set. This tells the server to not return this information back to the client.

If you are running a standard query in the Query Analyzer or Management Studio and you aren’t getting the information back, it’s because the SET NOCOUNT ON flag has been set, either on your client as a default, or on the server as a default. You can change this by putting SET NOCOUNT OFF in your query above the statement that you want to see the rowcount for.

You can also request after running your query the value of the @@ROWCOUNT variable and return this information.

<pre>UPDATE YourTable
SET Column = ‘YourValue’
WHERE AnotherColumn = 3

SELECT @@ROWCOUNT</pre>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following