Как получить несколько значений выходных параметров в if else в хранимой процедуре SQL ?
I am writing stored procedure for login in which i want result through output parameters usertype and loginstatus values as 1 and 1 respectively. Following is stored procedure code: CREATE procedure [dbo].[usp_login] (@userid nvarchar(50), @password nvarchar(50), @usertype int output, @loginstatus int output) As Begin if exists(Select COUNT(User_Id) from User_Master where User_Id = @userid and Password = @password) begin select @usertype = User_Type from User_Master where User_Id = @userid and Password = @password; set @loginstatus = 1; end else begin set @usertype = 0 set @loginstatus = 0; end End I am executing the sp in ssms as follows: declare @usrtype int; declare @lgnstat int; exec usp_login 'a', 'a', @usrtype output, @lgnstat output print @usrtype print @lgnstat Now when i pass correct userid password i get result as 1,1 which is as expected. But, when i pass wrong userid or password i get result as 1 which is expected as 0,0. Please tell me where's the problem either in sp definition code or execution code ?
Что я уже пробовал:
CREATE procedure [dbo].[usp_login] (@userid nvarchar(50), @password nvarchar(50), @usertype int output, @loginstatus int output) As Begin if exists(Select COUNT(User_Id) from User_Master where User_Id = @userid and Password = @password) begin select @usertype = User_Type from User_Master where User_Id = @userid and Password = @password; set @loginstatus = 1; end else begin set @usertype = 0 set @loginstatus = 0; end End
declare @usrtype int; declare @lgnstat int; exec usp_login 'z', 'z', @usrtype output, @lgnstat output -- passing wrong userid password print @usrtype print @lgnstat