Count rows in result of SQL query

To receive quantity of rows of the returned records of SQL query, you should use function @@ROWCOUNT. Function @@ROWCOUNT returns the quantity of rows, which were used in a query.

Result is: 188


In this case it means that table "Users" has 188 records because it returns all rows.

One of practice tutorials for the function @@ROWCOUNT is to count how many rows where updated after SQL update query. You can see an example of usage @@ROWCAOUNT after update:


The value of @@ROWCOUNT has been changed after each query. That’s why in this example you can see the variable @S which value is equal to @@ROWCOUNT after UPDATE query.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment Notes of web-specialist
Since 2009