In how many ways we can get a table's row count?

 Posted by vishalneeraj-24503 on 2/2/2015 | Category: Sql Server Interview questions | Views: 1206 | Points: 40

1. Using COUNT(*)
Select count(*) from employee_master;

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

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

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

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

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response