Tuesday 19 July 2016

Stored Procedure with both input and output parameters

Store Procedure
CREATE PROCEDURE [dbo].[GetPermission]
    @userName varchar(50),
    @permission int output
AS
BEGIN

    select @permission = PERMISSION from USERS where UserName = @userName

END;
EDIT:
another option is create a function instead, example:
CREATE FUNCTION [dbo].[GetPermission](@userName [varchar(50)])
RETURNS [int] 
AS 
BEGIN

    declare @permission int

    select @permission = PERMISSION from USERS where UserName = @userName

    return @permission

END;

No comments:

Post a Comment