如何用SQL语句,查出数据库中所有记录为空的表?

qwerttyy 2006-11-17 03:26:43
RT

谢谢~
...全文
382 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shanglivv7713 2006-11-17
  • 打赏
  • 举报
回复
呵呵!快给分吧
greenberet007 2006-11-17
  • 打赏
  • 举报
回复
学习
qwerttyy 2006-11-17
  • 打赏
  • 举报
回复
找到方法了,不用这么麻烦

select sysobjects.name,rows from sysobjects,sysindexes where sysobjects.name=sysindexes.name and xtype='u' and rows=0

crazyflower 2006-11-17
  • 打赏
  • 举报
回复
create table ttt
(
aa nvarchar(50)
)
declare @TableName nvarchar(50)
declare cursor_1 cursor for select name from sysobjects where xtype='U'
open cursor_1
fetch next from cursor_1 into @TableName
while @@fetch_status=0
begin
exec ('if (select count(*) from '+@TableName+')=0 insert into ttt values ('''+@TableName+''')')
fetch next from cursor_1 into @TableName
end
select * from ttt
drop table ttt
close cursor_1
deallocate cursor_1

34,588

社区成员

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

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