How to retrieve All Tables and Number of Rows on Sql Server.

 Posted by Vishalneeraj-24503 on 5/16/2015 | Category: Sql Server Interview questions | Views: 243 | Points: 40
Answer:

Write below query:-
SELECT OBJECT_NAME(Object_id) As TableName, SUM(Rows) As TotalRows

FROM sys.partitions
WHERE OBJECTPROPERTY(Object_id, 'IsUserTable') = 1 AND Index_ID IN (0,1)
GROUP BY OBJECT_NAME(Object_id)
ORDER BY TableName;


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response