Tuesday, 16 September 2014

Sql Server Stored Procedure to Authenticate User with output paramater

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


--AUTHOR:    MANOJ KUMAR
--PURPOSE:     AUTHONTICATE USER

CREATE PROCEDURE [dbo].[AUTHENTICATE_USER_LOGIN]
(
    @PASSWORD VARCHAR(50),
    @LOGIN_ID VARCHAR(200),
    @OUTPUT VARCHAR(200) OUTPUT

)
AS
    DECLARE @COUNT INT
    BEGIN
        /*SET @COUNT =  (SELECT COUNT(*) FROM USER_REGISTRATION WHERE CAST ([PASSWORD] AS BINARY)= CAST(@PASSWORD AS BINARY)
        AND CAST([LOGIN_ID] AS BINARY)=CAST(@LOGIN_ID  AS BINARY)  AND REC_STATUS =1)*/

        SET @COUNT =  (SELECT COUNT(0) FROM USER_REGISTRATION WHERE [PASSWORD] =  @PASSWORD
        AND CAST([LOGIN_ID] AS BINARY)=CAST(@LOGIN_ID  AS BINARY)  AND IS_RECSTATUS =1);

        IF (@COUNT > 0)
        BEGIN
            SET @OUTPUT ='YES'
        END
        ELSE
        BEGIN
            SET @OUTPUT ='NO'
        END
    END
--    RETURN @OUTPUT
GO

No comments:

Post a Comment