SQL里能筛选出一部分没用的表吗?~

ladyling 2005-02-24 03:51:23
有个数据库里有大概2000个表
但有80%是没数据的
我想找一些有用的数据,但不可能每个表逐个打开
请问怎么筛选掉一些空表
...全文
109 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdhdy 2005-02-24
  • 打赏
  • 举报
回复
select a.name 表名 from sysobjects a join sysindexes b on a.xtype='U' and a.status>0 and a.id=b.id and b.indid<2 and b.rows>0 order by a.name
Softlee81307 2005-02-24
  • 打赏
  • 举报
回复
Declare @s varchar(50),@p varchar(1000)
Declare kk cursor for
select name from sysobjects where xtype='U'
open kk
fetch next from kk into @s
while @@fetch_status=0
begin
set @p='if not exists(select * from '+@s +' ) select ''' + @s+''''
exec(@p)
fetch next from kk into @s
end
close kk
deallocate kk

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧