存储过程传参数
where BankID in (@strBank) , 传进去的变量值是“1,2,3”,执行时转int失败,要怎么弄啊
------解决方案--------------------方法一:
--半角逗号
where charindex( ', '+cast(BankID as varchar)+ ', ', ', '+@strBank+ ', ') > 0
--全角逗号
where charindex( ', '+cast(BankID as varchar)+ ', ', ', '+@strBank+ ', ') > 0
方法二:
exec ( '... where BankID in ( '+@strBank+ ') ')
------解决方案--------------------where charindex(cast(BankID as varchar),@strBank)> 0
------解决方案--------------------declare @sql varchar(1024)
set @sql= 'select * from tablename where BankID in ( ' + @strBank + ') '
exec(@sql)
要用动态语句