展开全部

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

create proc [dbo].[yyy] @str varchar(100)

as

declare @s varchar(8000)

declare tb cursor local for

select s='if exists(select 1 from ['+b.name+'] where convert(varchar,['+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,56,60,108,106)

open tb

fetch next from tb into @s

while @@e69da5e887aa3231313335323631343130323136353331333335303536fetch_status=0

begin

exec(@s)

fetch next from tb into @s

end

close tb

deallocate tb

MS数据库的,MYSQL不熟悉,你可以试试能不能用。

exec yyy '字段的值‘

下面是执行结果

d7303cbdf6955b160a7080c8fc78560e.png

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐