SSRS中多值参数怎么处理

我的rdl文件中有一个多值参数@pn_id,
当用户输入多个值后,会进行查询,不在table中的id,会给出一个not exists并显示在页面Matrix中
我的sql语句是

declare  @tb table(b varchar(max))
        if @pn_id is not null
        begin
                    set @pn_id= REPLACE(@pn_id,'''','')
        insert into @tb select @pn_id b ;
        select c.split,'Not Exists' as Pstate from (
        select SUBSTRING(t.b, number ,CHARINDEX(',',t.b+',',number)-number) as split
        from @tb t,master..spt_values s where s.number >=1 and s.type = 'P' and SUBSTRING(','+t.b,s.number,1) = ',' ) c where c.split not in
        (SELECT   pn_id FROM  pentable 
        end
        else
        begin
        select null as split, null as Psatet
        end`

我在报表中使用这段句子的时候是报错的,应该怎么修改才能达到效果呢?
当我执行 这个句子的时候是可以得出结果的,但一旦改为动态执行时,却报错

select * from pentable where pen_id in(@pn_id) 

decalre @sql varchar(max)
set @sql='select * from pentable where pen_id in(+@pn_id+)'

下面这个句子报表中执行的时候报错,为什么呢? 求解决办法啊

应该改成set @sql='select * from pentable where pen_id in('+@pn_id+')'