如何查一个表中所有字段是否包含某个关键词

declare @n varchar(30)
declare @key varchar(20)
set @key='关键字'
declare cur cursor for
select a.name from syscolumns a Inner Join systypes b on a.id=b.id where id=object_id('表') and b.name in('varchar','char','nvarchar','nchar','sysname')
fetch next from cur into @n
while @@fetch_status=0
begin
if exists(select 1 from [表] where charindex(@key,@n)>0)
   print @n +'中存在!'
fetch next from cur into @n
end
close cur
deallocate
 

你可能感兴趣的:(sql)