我写了一个存储过程来返回一个计数.但我得到了一个空值.任何人都可以告诉我存储过程中的问题在哪里.
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[ValidateUser] @UserName varchar(50),@Password varchar(50),@Num_of_User int output AS BEGIN SET NOCOUNT ON; SELECT @Num_of_user =COUNT(*) FROM login WHERE username = @UserName AND pw = @Password RETURN END
解决方法
您将值设置为变量@num_of_user.在查询后添加select @num_of_user
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[ValidateUser] @UserName varchar(50),@Num_of_User int output AS BEGIN SET NOCOUNT ON; SELECT @Num_of_user =COUNT(*) FROM login WHERE username=@UserName AND pw=@Password SELECT @Num_of_user return END