如何在SQL Server中查找没有记录的表的列表 [英] How to find list of tables having no records in SQL server
本文介绍了如何在SQL Server中查找没有记录的表的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何显示表中没有记录的表的列表,并且这些表已存在于sql server数据库中。仅需要显示表中没有记录的表。
How to display a list of tables having no record in them and they are existing in the sql server database.Required is only to show tables with no record in them.
推荐答案
尝试一下:
SELECT
t.NAME AS TableName,
p.rows AS RowCounts
FROM
sys.tables t
INNER JOIN
sys.partitions p ON t.object_id = p.OBJECT_ID
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND p.rows = 0
GROUP BY
t.Name, p.Rows
ORDER BY
t.Name
查询进入 sys.tables
和其他目录视图来查找表,它们的索引和分区,以找到行计数为0的表。
The query goes to the sys.tables
and other catalog views to find the tables, their indexes and partitions, to find those tables that have a row count of 0.
这篇关于如何在SQL Server中查找没有记录的表的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文