sql查询数据库中所有 ,数据为空的表
查询数据库中所有为空的表,以下是在sqlserver中的查询语句,联合查询主要是想把表的描述也加载进来
(多个表名为'dtproperties' 的话 忽略 )
--查询数据为空的所有表 SELECT TnoData.Tname ,Tall.Tdes,TnoData.Trows FROM ( SELECT a.name Tname, b.rows Trows FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id WHERE (a.type = 'u') AND (b.indid IN (0, 1)) and b.rows=0 ) TnoData --为空的表名和行数 left join ( SELECT tbs.name Tname,ds.des Tdes ,ds.minor_id FROM ( SELECT ds.value des ,ds.minor_id,ds.major_id FROM sys.extended_properties ds where ds.minor_id=0 ) ds RIGHT JOIN sysobjects tbs ON ds.major_id=tbs.id where tbs.xtype='U' ) Tall --所有表名和表的描述 on TnoData.Tname=Tall.Tname order by TnoData.Tname