34,590
社区成员
发帖
与我相关
我的任务
分享
--创建函数
create function fun_a(@articleID int)
returns varchar(8000)
as
begin
declare @str varchar(8000)
set @str=''
select @str=@str+'and article的列 like '+'''%'+rtrim(key的列)+'%''' from key where articleID=@articleID
return @str
end
----执行
declare @sql varchar(8000)
set @sql='select * from article a where (1=1'+dbo.fun_a(a.articleID) +')'
exec(@sql)