Technical Article

Row counts for all tables in a database

,

I saw a script on here that outputs commands to the messages pane in Query Analyser. When run, these scripts output row counts for all your tables. This script does the same thing, but in one step.

Tested on SQL Server 2000.

exec sp_msforeachtable @command1="declare @count int; SELECT @count = COUNT(*) FROM ?; print '? - ' + cast(@count as nvarchar(100))"

Rate

3.4 (5)

Share

Share

Rate

3.4 (5)