为什么只有一个名字显示?
我有一函数:
CREATE function GetNames(@pid varchar)
returns varchar(8000)
as
begin
declare @names varchar(1000)
set @names = ' '
select @names = @names + ', ' + tag from all_adv_cls where id in (@pid)
set @names = stuff(@names ,1,1, ' ')
return @names
end
@pid 传进去是 1,2,3 为什么出来的 @names只有一个值,没有id对应的name1,name2,name3 ??
帮助解决一下,先谢!
------解决方案--------------------CREATE function GetNames(@pid varchar)
returns varchar(8000)
as
begin
declare @names varchar(1000)
set @names = ' '
select @names = @names + ', ' + tag from all_adv_cls where charindex( ', '+id+ ', ', ', '+@pid+ ', ')> 0
set @names = stuff(@names ,1,1, ' ')
return @names
end