/ Published in: SQL

This will return a list of all the tables in a certain database along with their row count.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
SELECT DISTINCT CONVERT(VARCHAR(30),object_name(a.id)) [TABLE Name], a.rows FROM sysindexes a INNER JOIN sysobjects b ON a.id = b.id INNER JOIN INFORMATION_SCHEMA.TABLES c ON c.[TABLE_NAME]=CONVERT(VARCHAR(30),object_name(a.id)) WHERE c.Table_catalog='DATABASE NAME'
Comments
