Search This Blog

Wednesday, January 12, 2011

row count for all the tables in db

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

or

SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_countFROM sys.dm_db_partition_stats stWHERE index_id < 2ORDER BY 1

No comments:

Post a Comment