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.



MarkiMarta.com. Notes of web-specialist
Since 2009
18+
Transact SQL: Get list of all databases in server

How to get as SQL query result the list of databases in SQL server. select name, database_id  from sys.databases  

Close