So, as data technology is always progressing (or should i say ‘moving’, that leaves room for any direction ) .. I plan to write some more posts on queries i use less often but are still handy.
The first one is about listing rights on the database objects, what users / groups have which rights on which objects? The script will retrieve Roles / external groups / sql users and so on!
SELECT dbpr.name As Username
, dbpr.type_desc AS [User Type]
, dbpe.permission_name AS [Permission]
, dbpe.state_desc AS [Permission State]
, dbpe.class_desc Class
, object_name(dbpe.major_id) AS [Object Name]
FROM sys.database_principals dbpr
LEFT JOIN
sys.database_permissions dbpe
ON dbpe.grantee_principal_id = dbpr.principal_id