页面传的值是str=str1,str2
我是想通过str把两个参数传到存储过程 然后查询条件能满足name in('str1','str2')但是到执行sql语句是参数变为N'str1,str2', 这样就变成一个参数,用in来查询时就查询不到结果
应该怎么办呢,求高人指点SQL存储

解决方案 »

  1.   


    select * from HomeLava.dbo.Nop_ProductVariantAttributeValue 
      where Name in (@attributeValue)如果@attributeValue是参数不定的话应该怎么写,可能包含1个以上参数
      

  2.   

     
    string code= "str1,str2";
    string.Format("select * from table(nolock) where cols in({0})", code);
    have a try!
      

  3.   


    Create proc p_getNop_ProductVariantAttributeValue
    @attributeValue nvarchar(100)
    asset @attributeValue=replace(@attributeValue,',',''',''')
    declare @str nvarchar(1000)
    set @str='select * from HomeLava.dbo.Nop_ProductVariantAttributeValue where Name in ('''+@attributeValue+''')'
    exec (@str)