Luouy~羽林
学问如逆水行舟,不进则退; 有知识的人不实践,等于一只蜜蜂不酿蜜; 我们可以由读书而收集知识,但必须利用思考把糠和谷子分开
declare @str varchar(100)
set @str='系统'
declare @s varchar(max)
declare c_tb cursor local for --申明游标
  select b='if exists(select 1 from  ['+b.name+'] where ['+a.name+'] like ''%'+@str+'%'')  
  print  ''select ['+a.name+'] from ['+b.name+']'''  
  from   syscolumns   a   join   sysobjects   b   on   a.id=b.id  
  where   b.xtype='U'   and   a.status>=0  
     and   a.xusertype   in(175,239,231,167) 
open c_tb
fetch next from c_tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch next from c_tb into @s
end
close c_tb
deallocate c_tb
posted on 2011-02-25 14:57  羽林.Luouy  阅读(763)  评论(0编辑  收藏  举报