存储过程参数问题,急!在线等回
SQL语句
select * from user where id in ('1','2','3','4','5','6')
现在想把他弄成存储过程, 可是这个参数('1','2','3','4','5','6'), 怎么搞? 求讲解. 不胜感激!
------解决方案--------------------create procedure pro_tb_Select
@id1 nvarchar(50),
@id2 nvarchar(50)
as
select * from user where id in (@id1,@id2)
go
execute pro_tb_Select '1','2'
go
------解决方案--------------------用一个nvarchar类型参数传入
------解决方案--------------------改造一下:
create procedure pro_tb_Select
@id1 nvarchar(3000)
as
select * from [user] where id in (@id1)
go
execute pro_tb_Select '1','2'
go
------解决方案--------------------下面一行改成这样
execute pro_tb_Select '1,2'
go
------解决方案--------------------in()里是个集合,@id是一个参数,这样是不行的,用sql语句拼接 ,然后 exec吧
http://bbs.csdn.net/topics/110108650