返回首页

您好,

像我写
存储过程


ALTER proc [dbo].[testmultiplevalues](@emailid varchar(max)=null, @currlocation varchar(max)=null,@gender varchar(max)=null)

as

begin

declare @selquery varchar(max)

declare @concat varchar(max)

set @concat = ' '

set @selquery='select Emailid, currentlocation,Gender from userdetails where '

if(@emailid is not null)

begin

set @selquery=@selquery + 'Emailid=' +@emailid

set @concat=' and '

end

if(@currlocation is not null)

begin

set @selquery=@selquery + @concat + 'currentlocation=' +@currlocation

set @concat=' and '

end

if(@gender is not null)

begin

set @selquery =@selquery + @concat +'Gender=' + @gender

end

exec @selquery

end


进程创建successfully.but时IAM执行PROC IAM得到
错误 {C} 请帮我:7932936 |会员

回答

评论会员:迪伦莫利 时间:2012/02/06
除了其他的答案,你还需要串资格你的一些变量

您的SQL正在建...

{体C3}
这将需要阅读如

{的C4}
评论会员:Naerling 时间:2012/02/06
很显然,你有没有为你做什么的线索...
不会使您的查询优化利用查询缓存(这使得它慢),这是容易出现SQL注入,这是不可能的阅读。
其实,你在那里做毫无意义的。
我建议你​​读{A}
之后,你可能会看到{A2}] ...
评论会员:sachin10d 时间:2012/02/06
试试这个

{C5的}:会员7932936:我错过了EXEC括号(可变)