Thursday, 9 May 2013

Microsoft SQL Server - Query to find the record counts of tables

Hi Everyone,

Use the below query to find the record count of tables.




SELECT
SCHEMA_NAME(T.SCHEMA_ID) AS SCHEMA_NAME,
T.NAME AS TABLE_NAME,
SCHEMA_NAME(T.SCHEMA_ID) + '.' + T.NAME AS FULL_TABLE_NAME,
I.ROWS
FROM
SYS.TABLES AS T INNER JOIN SYS.SYSINDEXES AS I
ON T.OBJECT_ID = I.ID AND I.INDID < 2
WHERE
SCHEMA_NAME(T.SCHEMA_ID)='DBO'
AND T.NAME IN ('Table1','Table2','Table3','TableN')


Thanks for reading my Blog !

0 comments:

Post a Comment