Created
March 12, 2012 18:54
-
-
Save justintoth/2023952 to your computer and use it in GitHub Desktop.
RBA_Get_PermissionsByRole
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[RBA_Get_PermissionsByRole] | |
@RoleId INT | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
SELECT p.id as PermissionId, p.Name, p.[key] as [Key], parent.[key] as ParentKey, p.MaxBits, p.MinBits, rp.PermissionBit, dp.[key] as [Dependency] | |
FROM role_permission rp WITH (NOLOCK) | |
JOIN permission p WITH (NOLOCK) ON rp.permissionid = p.id | |
LEFT JOIN permission parent WITH (NOLOCK) ON p.parentid = parent.id | |
LEFT JOIN permissiondependency dep WITH (NOLOCK) ON p.id = dep.permissionid | |
LEFT JOIN permission dp WITH (NOLOCK) ON dep.dependentpermissionid = dp.id | |
WHERE rp.Roleid = @RoleId | |
AND p.id IN | |
( | |
SELECT permissionid | |
FROM company_permission cp WITH (NOLOCK) | |
JOIN role r WITH (NOLOCK) ON cp.companyid = r.companyid | |
WHERE r.id = @roleid | |
) | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment