set @SQL='set @Other='''' select @Other = @Other + name + ''<br>''
from others where otherId in @OtherId'改成如下:
set @SQL='set @Other='''' select @Other = @Other + name + ''<br>''
from others where otherId in ('+@OtherId+')'
from others where otherId in @OtherId'改成如下:
set @SQL='set @Other='''' select @Other = @Other + name + ''<br>''
from others where otherId in ('+@OtherId+')'
declare @SQL nvarchar(500)
declare @OtherId varchar(100)
set @OtherId='1,2'set @SQL='set @Other='''' select @Other = @Other + name + ''<br>''
from others where otherId in (' + @OtherId +')'
exec sp_executesql @SQL,
N' @Other varchar(250) output, @OtherId varchar(100)',
@Other output, @OtherIdselect @Other