海海日记-冯海滨博客

您现在的位置是:首页 > SQL > 正文

SQL

SQL检索X数据库中 所有表记录行数小于2的表 返回数据库中记录行数小于2的所有表名

happyfhb2013-09-01SQL1265
declare @dbname nvarchar(200)
declare @str_sql nvarchar(200)
declare curdb cursor for
select name from sysobjects where  xtype='U' --找出数据库中的所有表

open curdb
fetch next from curdb into @dbname
while @@fetch_status=0
begin
select @str_sql='if exists(select * from (Select count(*) as num From '+ @dbname +')tmp where num<2)   print '''+ @dbname +''' + char(13)'
--print @str_sql
 exec (@str_sql )
 fetch next from curdb into @dbname
end
close curdb
deallocate curdb


平淡中储蓄成长

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~