Created
July 3, 2026 15:39
-
-
Save Himura2la/cf9ee46a0e29390dbd074b324c15f101 to your computer and use it in GitHub Desktop.
List all EntraID uses in Azure SQL database
This file contains hidden or 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.name, dp.type_desc, STRING_AGG(r.name, ', ') WITHIN GROUP (ORDER BY r.name) AS roles | |
| FROM sys.database_principals dp | |
| LEFT JOIN sys.database_role_members rm ON rm.member_principal_id = dp.principal_id | |
| LEFT JOIN sys.database_principals r ON r.principal_id = rm.role_principal_id | |
| WHERE dp.type IN ('E', 'X') | |
| GROUP BY dp.name, dp.type_desc | |
| ORDER BY dp.name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment