"AddRole" Stored Procedure

Description:

This stored procedure adds a new role to the database for the specific portal. The input parameters include PortalID and RoleName. The output parameter is the RoleID of the new database record.

Definition:
    
    CREATE PROCEDURE AddRole
    (
	    @PortalID    int,
	    @RoleName    nvarchar(50),
	    @RoleID      int OUTPUT
    )
    AS

    INSERT INTO Roles
    (
        PortalID,
        RoleName
    )

    VALUES
    (
        @PortalID,
        @RoleName
    )

    SELECT
        @RoleID = @@Identity
        
Database Tables Used:

Roles:  Each record in the Roles table defines a unique role in the selected portal. Users are added to a role via the UserRoles lookup value table.

The primary key in this table is the RoleID identity field.