日期:2014-05-18  浏览次数:20340 次

问一存储过程
CREATE PROCEDURE [example1]
(@str varchar(500)  
)
AS

BEGIN  
select id from table1 where id in (@str)
end
go 
>>>>>>>>>>>
请问这样的写法有什么不对,为什么查询不出来,
@str 传入值是 1,4
table1 的记录是
id pstr
1 hello
2 hi
4 good
 

------解决方案--------------------
SQL code

select id from table1 where id in (@str) 
改为:
select id from table1 where charindex(','+id+',' , ','+@str+',')>0