Like带参
商品表Commodity,@Remark2的值直接是字符串 string remark2=”测试商品”
Select CommodityId,Price,CommodityName,CommodityCode
From Commodity
Where Disabled=@Disabled1 And Remark like '%'+@Remark2+'%'
In带参
商品表Commodity,@CommodityCodes的值直接是字符串 string commodityCodes=“‘C0001’,’C0002’,’C0005’”
exec('SELECT CommodityId,Price,CommodityName,CommodityCode
FROM Commodity
WHERE Disabled=0 AND CommodityCode IN ('+@CommodityCodes+')
')