存储过程 in的问题?
create procedure Test
(
@user varchar
@icUrl varchar
)as
exec( 'select * from A表 where user= ' '+@user+ ' ' and Icon_Url in( ' '+@icUrl+ ' ') ')
其中传递的参数值如下:
@user= 'aabb '
@icUrl= ' ' 'include/1.jpg ' ', ' 'include/2.jpg ' ' '
就是得不到需要的结果啊
exec 中的 后面那个参数的写法该如何写,谢谢
------解决方案--------------------exec( 'select * from A表 where user= ' '+@user+ ' ' and Icon_Url in( '+@icUrl+ ') ')
------解决方案--------------------exec( 'select * from A表 where user= ' ' '+@user+ ' ' ' and Icon_Url in( ' ' '+@icUrl+ ' ' ') ')
------解决方案--------------------declare @user VARCHAR(1000), @icUrl VARCHAR(1000)
set @user= 'aabb '
set @icUrl= ' ' 'include/1.jpg ' ', ' 'include/2.jpg ' ' '
print 'select * from A表 where user= ' ' '+@user+ ' ' ' and Icon_Url in( '+@icUrl+ ') '
exec( 'select * from A表 where user= ' ' '+@user+ ' ' ' and Icon_Url in( '+@icUrl+ ') ')
------------------------------------------
select * from A表 where user= 'aabb ' and Icon_Url in( 'include/1.jpg ', 'include/2.jpg ')