Table Row Counts

–Script from Dattatrey Sindol

SELECT  QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) + ‘.’ + QUOTENAME(sOBJ.name) AS [Table_Name] , SUM(sPTN.Rows) AS [Row_Count]

FROM     sys.objects AS sOBJ     

INNER JOIN sys.partitions AS sPTN

ON sOBJ.object_id = sPTN.object_id

WHERE  sOBJ.type = ‘U’ AND sOBJ.is_ms_shipped = 0x0

      AND index_id < 2 — 0:Heap, 1:Clustered

GROUP BY  sOBJ.schema_id, sOBJ.name

ORDER BY [Table_Name]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s