ALTER PROCEDURE [dbo].[Signin_Check]
@uid varchar(50), @pwd varchar(50), @uname varchar(50) output
AS
IF EXISTS (SELECT * FROM threeLayer_user WHERE uid = @uid and pass = @pwd)
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @uname = name
FROM threeLayer_user
WHERE uid = @uid and pass = @pwd
RETURN @uname
END
此存储过程引发错误:
将varchar值'Saurav'转换为数据类型int时,转换失败。
答案 0 :(得分:6)
您的代码包含
行return @uname
return语句只能接受整数值。但是,您的@uname参数是输出参数,因此您无需也返回它。只需确保在调用sproc时指定OUTPUT
:
EXEC dbo.Signin_Check @uid, @password, @uname OUTPUT;
答案 1 :(得分:0)
SP似乎没有与错误相关的错误代码,您能否检查传递给存储过程的参数(即它们的顺序和类型)?问题可能是您传递的值而不是实际的过程。
您可以在调用存储过程时将您正在使用的代码附加到帖子中吗?
答案 2 :(得分:0)
您确定它是varchar
列吗?
@uid varchar(50) / int
uid = @uid