存储过程传代单引号参数 在线等,马上给分, 急,,,

ptxiaolinzi886 2009-12-02 01:49:09
存储过程传代单引号参数 在线等,马上给分,

@iid在程序里的值是 1,2,4,5

存储过程
select * from biao where id in (@iid)


这样执行了就变为select * from biao where in ('1,2,4,5')

这样子是不行的,我想要的是select * from biao where in (1,2,4,5)
但是存储过程的变量默认是带单引号的,怎么办,,,如何解决,,急,,,
...全文
44 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
-狙击手- 2009-12-02
  • 打赏
  • 举报
回复
create proc sp_test
@iid varchar(100)
as
begin
exec('select * from biao where id in ('+@iid+')')
end
go

exec sp_test '1,2,4,5'
百年树人 2009-12-02
  • 打赏
  • 举报
回复
EXEC('select * from biao where id in('+@iid+')')

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧