Skip to main content
2 of 2
improved language/formatting
tinlyx
  • 3.7k
  • 14
  • 48
  • 79

With the following command I managed to get a more correct response :

SELECT state_desc
    ,permission_name
    ,'ON'
    ,class_desc
    ,SCHEMA_NAME(major_id)
    ,'TO'
    ,USER_NAME(grantee_principal_id)
FROM sys.database_permissions AS PERM
JOIN sys.database_principals AS Prin
    ON PERM.grantee_principal_id = Prin.principal_id
        AND PERM.class_desc = 'SCHEMA'

The thing is that Scott's answer I think the link between sys.database_permissions and sys.database_principals is incorrect. Why joining over major_id since that represents the schema and not the grantee (principal).

But thanks Scott !! your answer helps a lot !

Delta
  • 113
  • 2