首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

存储过程 in的有关问题

2012-01-20 
存储过程 in的问题?createprocedureTest(@uservarchar@icUrlvarchar)asexec( select*fromA表whereuser+@u

存储过程 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 ')

热点排行