Tuesday, April 4, 2023

SQL Azure User Permissions

 New Demand to find out the user permissions in Azure SQL Database. 

SELECT    roles.principal_id                            AS RolePrincipalID
  ,    roles.name                                    AS RolePrincipalName
  ,    database_role_members.member_principal_id    AS MemberPrincipalID
  ,    members.name                                AS MemberPrincipalName
FROM sys.database_role_members AS database_role_members  
JOIN sys.database_principals AS roles  
  ON database_role_members.role_principal_id = roles.principal_id  
JOIN sys.database_principals AS members  
  ON database_role_members.member_principal_id = members.principal_id;  
GO


Reference-> SQLShack
https://www.sqlshack.com/database-level-roles-in-azure-sql-database/#:~:text=Expand%20the%20Azure%20SQL%20DB,%3E%20Roles%20%2D%3E%20Database%20Roles.


No comments:

Post a Comment