There is error while executing stored procedure


Getting error in SQL server stored procedure when executing it:

    USE [ConsumerBanking]  
    GO  
    SET ANSI_NULLS ON  
    GO  
    SET QUOTED_IDENTIFIER ON  
    GO  
      
    CREATE  PROCEDURE [dbo].[GetCBLoginInfo]  
        @UserName VARCHAR(20),  
        @Password varchar(20)  
    AS  
    SET NOCOUNT ON  
    Declare @Failedcount AS INT  
    SET @Failedcount = (SELECT LoginFailedCount from CBLoginInfo WHERE UserName = @UserName)  
      
    IF EXISTS(SELECT * FROM CBLoginInfo WHERE UserName = @UserName)  
      
     BEGIN  
      
     IF EXISTS(SELECT * FROM CBLoginInfo WHERE UserName = @UserName AND Password = @Password )  
        SELECT 'Success' AS UserExists  
    ELSE  
      
    Update CBLoginInfo set  LoginFailedCount = @Failedcount+1  WHERE UserName = @UserName  
      
    Update CBLoginInfo set LastLoginDate=GETDATE()  WHERE UserName = @UserName  
     BEGIN  
    IF @Failedcount >=5  
      
      
    SELECT 'Maximum Attempt Reached (5 times) .Your Account is locked now.' AS UserExists  
    ELSE  
      
    select CONVERT(varchar(10), (SELECT LoginFailedCount from CBLoginInfo   WHERE UserName = @UserName))   AS UserFailedcount  
    END   
    END  
     ELSE  
      
     BEGIN   
      
    SELECT 'User Does not Exists' AS UserExists  
     END  

Asked by:- PranaliGholap
0
: 1379 At:- 2/29/2020 5:28:47 AM
SQL stored procedure

Can you edit your question and explain it in more detail like, what are your trying to do, what end result you want, table on which you are running stored procedure. please mention all the details. 0
By : vikas_jk - at :- 2/29/2020 8:25:23 AM






1 Answers
profileImage Answered by:- vikas_jk

It is diificult to understand what is the error and what are you trying to do, looking at procedure only.

If you are new to stored procedure and still learning about SQL server stored procedures, please check this article:

https://qawithexperts.com/article/sql/stored-procedure-in-sql-server-with-example/203

Also, please explain your question in detail, it should contain every detail like "what are your trying to do? what end result you expect? sql table on which you are running stored procedure?" so we can understand and solve your query accordingly, if possible.

1
At:- 2/29/2020 8:30:13 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use