Passing multiple values for one SQL parameter

后端 未结 3 1178
梦如初夏
梦如初夏 2020-12-10 08:54

I have a CheckBoxList where users can select multiple items from the list. I then need to be able to pass these values to my Stored Procedure so they can be used in a WHERE

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 09:25

    alter procedure c2
    (@i varchar(5))
    as
    begin
        declare @sq nvarchar(4000)
        set @sq= 'select * from test where id in () '
        SET @sq= REPLACE(@sq, '', @i)
        EXECUTE sp_executesql  @sq
    end
    
    exec c2 '1,3'
    

提交回复
热议问题