August 26, 2016 at 5:36 am
Hi all!
I have a db with app. 500 tables.
Many af them are empty, or has just a very few records.
Now i need to make a script, that creates tablename, count(records table) for all tables in the db.
sorted on count,name
How to?
Best regards
Edvard Korsbæk
August 26, 2016 at 5:54 am
SELECT OBJECT_NAME(object_id) AS TableName, SUM(rows) AS Rows FROM sys.partitions
WHERE index_id IN (0,1)
AND OBJECTPROPERTY(object_id, 'IsMSShipped') = 0
GROUP BY object_id
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 26, 2016 at 6:08 am
Thanks as so many times before.
I should document the tables to national achives in Denmark, and this answer makes it possible to ducument, that i need no documentation for app. 50 % of the tables..
Best regards
Edvard Korsbæk
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply