List all tables and their row counts
Just find few useful tips/tool when I try to compare the schema and content of two SQL databases:
- DBComparer (free)
- Find out DB lock: select distinct object_name(a.rsc_objid), a.req_spid, b.loginame from master.dbo.syslockinfo a (nolock) join master.dbo.sysprocesses b (nolock) on a.req_spid=b.spid where object_name(a.rsc_objid) is not null
- List all tables in database: SELECT * FROM sys.Tables
- List all tables and their row counts
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.rows)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U'
AND
si.id = OBJECT_ID(so.name)
GROUP BY
so.name
ORDER BY
2 DESC