Tuesday, 16 September 2014

Stored Procedure to search user by Username or Userid

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE procedure [dbo].[SEARCH_USER]
(
    @USER_FIRST_NAME VARCHAR(100),
    @USER_ID_PK         BIGINT
)
AS
BEGIN
    IF LEN(@USER_ID_PK) > 0
    BEGIN
        SELECT * FROM USER_REGISTRATION WHERE USER_ID_PK = @USER_ID_PK AND IS_RECSTATUS = 1;
    END
    ELSE
    BEGIN
        SELECT * FROM USER_REGISTRATION WHERE USER_FIRST_NAME LIKE @USER_FIRST_NAME AND IS_RECSTATUS = 1 ORDER BY USER_FIRST_NAME;
    END

END

No comments:

Post a Comment