How to query the SQL server to fetch the effective permission of the following SQL logins under the Security/Logins:
- SQL user
- Windows user
- Windows group
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
You can use the system view
sys.server_permissions to query for all server level permissions (which would include permissions assigned to Logins). If you join it to the
sys.server_principals system view, you can get information about the Login itself as well.
Example from the aforementioned docs:
SELECT pr.principal_id, pr.name, pr.type_desc, pe.state_desc, pe.permission_name FROM sys.server_principals AS pr JOIN sys.server_permissions AS pe ON pe.grantee_principal_id = pr.principal_id;
You may also be interested in the system view
sys.database_permissions to query for database specific permissions for any database Users associated with those Logins.