SQL server stored procedure return a table

后端 未结 9 2234
情书的邮戳
情书的邮戳 2020-12-04 19:39

I have a stored procedure that takes in two parameters. I can execute it successfully in Server Management Studio. It shows me the results which are as I expect. However it

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 20:20

    Though this question is very old but as a new in Software Development I can't stop my self to share what I have learnt :D

    Creation of Stored Procedure:

    CREAET PROC usp_ValidateUSer
    (
        @UserName nVARCHAR(50),
        @Password nVARCHAR(50)
    )
    AS
    
    BEGIN
        IF EXISTS(SELECT '#' FROM Users WHERE Username=@UserName AND Password=@Password)
        BEGIN
            SELECT u.UserId, u.Username, r.UserRole
            FROM Users u
            INNER JOIN UserRoles r
            ON u.UserRoleId=r.UserRoleId
        END
    END
    

    Execution of Stored Procedure:

    (If you want to test the execution of Stored Procedure in SQL)

    EXEC usp_ValidateUSer @UserName='admin', @Password='admin'
    

    Th Output:

提交回复
热议问题