我的数据库中有100个表。现在我不知道所有的桌面名称还有10条记录 [英] I Have 100 Tables In My Database. Now I Wont All The Table Names Which Has More Then 10 Records
本文介绍了我的数据库中有100个表。现在我不知道所有的桌面名称还有10条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的数据库中有100个表。现在我想要所有包含10个以上记录的表名。但我不想每次检查各个表。所以请帮助我们。
提前致谢我希望我能得到答案。
Hi Guys,
I have 100 tables in my database. Now i want all the table names which has more then 10 records. But i don't want to check the individual tables every time. So please help me guys.
Thanks in advance and i hope i will get the answer.
推荐答案
一个快速的方法,从sys.partitions中获取它,因为直接使用COUNT(*)命中db中的所有表可能非常耗时。
A quick way to do it, to get it from sys.partitions, since directly hitting all tables in db with COUNT(*) can be quite time consuming.
SELECT OBJECT_SCHEMA_NAME(p.object_id) [Schema]
, OBJECT_NAME(p.object_id) AS [Table]
, p.partition_number
, p.rows AS [Row Count]
FROM sys.partitions p
WHERE OBJECT_SCHEMA_NAME(p.object_id) <> 'sys'
AND p.rows > 10
这篇关于我的数据库中有100个表。现在我不知道所有的桌面名称还有10条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文