当前位置: 代码迷 >> Sql Server >> 问一存储过程解决思路
  详细解决方案

问一存储过程解决思路

热度:145   发布时间:2016-04-27 19:25:17.0
问一存储过程
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+',' , ',[email protected]+',')>0
  相关解决方案