SQL Server 2005中的存储过程错误 [英] stored procedure error in sql server 2005
本文介绍了SQL Server 2005中的存储过程错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Create PROCEDURE CheckUserName
(
@name nvarchar(50), --Input parameter , Studentid of the student
@return int OUT -- Out parameter declared with the help of OUT keyword
)
AS
begin
declare @pid int;
set @pid=(select name from login where name=@name);
if(@pid=1)
begin
set @return=1
end
else
set @return=0
end
execute CheckUserName 'sankar'
执行程序时显示错误.请帮我解决这个问题
while executing the procedure its showing error.please help me for this
推荐答案
您必须使用诸如此类的out参数执行过程
Hi ,
You have to Execute procedure with out parameter like this
DECLARE @OutValue int
EXECUTE CheckUserName 'sankar',@OutValue OUT
SELECT @OutValue
最好的问候
M.Mitwalli
Best Regards
M.Mitwalli
set @pid=(select name from login where name=@name);
是int
类型的"名称"吗?我怀疑是否像在您的where
子句中那样将 name 与 @name (即varchar
)
进行比较
因此,无论哪种方式,如果 name 是int
类型,则您的where
子句将引发错误;或者,如果 name 是varchar
类型,则您的集合将引发错误.
更正数据类型比较/分配.
Is ''name'' of int
type? I doubt that as in your where
clause you compare name with @name (that is varchar
)
So, either ways, if name is int
type then your where
clause would throw an error OR if name is varchar
type then your set would throw an error.
Correct the datatype comparison/assignment.
这篇关于SQL Server 2005中的存储过程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文