Many ways of getting a table’s row count in Sql Server.

Posted by Vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 633
1. Using COUNT(*)
Select count(*) from table1;

2. using COUNT(1)
select count(1) from table1;

3. Using SUM() aggregate function
select sum(1) from table1;

4. Using sysindexes view
select object_name(id),rows 
from sys.sysindexes
where object_name(id) = 'table1' and indid<2;

5. Using sp_spaceused system SP
exec sp_spaceused 'table1';

Comments or Responses

Login to post response