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