admin管理员组文章数量:1794759
sqlserver数据库sql语句搜索空表和非空表
查询数据库空表有哪些:
use 库名 go declare @tablename nvarchar(100) declare @sql nvarchar(2000) declare @count int declare @a int declare cur_c cursor for select name from sysobjects where xtype='U' and status>=0 open cur_c fetch next from cur_c into @tablename while @@fetch_status = 0 begin set @sql='select @a=count(*) from '+@tablename+'' exec sp_executesql @sql,N'@a int output',@count output if @count=0 print @tablename fetch next from cur_c into @tablename end close cur_c deallocate cur_c查询数据库非空表有哪些
--这个根据存储区来判断 select B.name from sys.partitions A inner join sys.objects B on A.object_id=B.object_id where B.type='U' and A.rows>0 --这个根据索引表来判断 select B.name from sysindexes A inner join sys.objects B on A.id=B.object_id where B.type='U' And A.rows >0版权声明:本文标题:sqlserver数据库sql语句搜索空表和非空表 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686656264a91290.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论