日期:2014-05-18 浏览次数:20569 次
exec pro_test 001,002,003
------解决方案--------------------
exec pro_test "'001','002','003'"
存储过程这样写
declare @sql nvarchar(500)
select @sql='select * from test where id in('+@param+')'
exec(@sql)
------解决方案--------------------
改:exec pro_test '''001'',''002'',''003'''
------解决方案--------------------
create proc pro_test
(@id varchar(200))
as
begin
declare @sql varchar(800)
set @sql='select * from test where id in('+@id+')'
print @sql
end
exec pro_test '001,002,003'
--执行结果
select * from test where id in(001,002,003)
或者
exec pro_test '''001'',''002'',''003'''
--执行结果
select * from test where id in('001','002','003')