34,591
社区成员
发帖
与我相关
我的任务
分享
create proc f_search
@keyword int,
@text nvarchar(2000),
@ret int out
as
begin
create table ##(id int identity(1,1),skey int)
declare @s varchar(8000)
set @s = 'insert ##(skey) select '+replace(@text,',',' union select ')
exec(@s)
select @ret = id from ## where skey = @keyword
drop table ##
end
go
declare @i int
exec f_search 26,'2,3,5,11,26',@I out
select @I
drop proc f_search
/*
-----------
5
(所影响的行数为 1 行)
*/