Created
June 22, 2019 04:22
-
-
Save akramarev/639f4a1cfdab99820c7c5007a38ecefc to your computer and use it in GitHub Desktop.
[get all mssql permissions grants]
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
SELECT | |
( | |
dp.state_desc + ' ' + | |
dp.permission_name collate latin1_general_cs_as + | |
' ON ' + '[' + s.name + ']' + '.' + '[' + o.name + ']' + | |
' TO ' + '[' + dpr.name + ']' | |
) AS GRANT_STMT | |
FROM sys.database_permissions AS dp | |
INNER JOIN sys.objects AS o ON dp.major_id=o.object_id | |
INNER JOIN sys.schemas AS s ON o.schema_id = s.schema_id | |
INNER JOIN sys.database_principals AS dpr ON dp.grantee_principal_id=dpr.principal_id | |
WHERE dpr.name NOT IN ('public','guest') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment