COUNT in SQL SERVER

COUNT is one of the most frequently used aggregate function in SQL SERVER.
As the indicated it counts the number of rows or records in the table.

Generally COUNT function is used to find out the number of rows in a table.
Syntax for the COUNT functions is:

SELECT COUNT(*) FROM <Table Name>
SELECT COUNT(1) FROM <Table Name>

Example:

Lets find out the number of rows in STUDENTS table using COUNT.

Query:

SELECT COUNT(*) FROM STUDENTS
SELECT COUNT(1) FROM STUDENTS 

Both of the above queries will return the same result.

Result Set:


This entry was posted in , . Bookmark the permalink.

Leave a reply