Friday, December 9, 2016

List of Tables with Row Count

Execute below script in a database to get Table Name and Rowcount .


SELECT
    t.NAME AS TableName,
    p.rows AS RowCounts
FROM
    sys.tables t
INNER JOIN
    sys.partitions p ON t.object_id = p.OBJECT_ID
WHERE
    t.NAME NOT LIKE 'dt%'
    AND t.is_ms_shipped = 0
 --   AND p.rows = 0
GROUP BY
    t.Name, p.Rows
ORDER BY
    t.Name

No comments:

Post a Comment