Take a look at this blog post from Sebastian Meine: https://sqlity.net/en/2584/script-database-permissions/
Query to return all users permissions on SQL Server
tobz
161
Reputation points
Hi everyone,
Please how can I use TSQL to get the list of all users detailed permissions and privileges on each database.
I want the query to return critieria like:
- Username
- Database name
- Login Type (SQL, Windows user or group, etc)
- Permission Type
- Permission State
- The specified object they have privileges on and they type of privileges.
- Roles (including the permission type, state and objects for each of the roles)
I need this information in a denormalized form if possible.
Thank you.
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,494 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
184 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,705 questions
2 answers
Sort by: Most helpful
-
Erland Sommarskog 120.5K Reputation points MVP Moderator
2024-08-27T21:16:07.83+00:00 -
LiHongMSFT-4306 31,551 Reputation points
2024-08-28T02:50:34.6933333+00:00 Hi @tobz
Try the upvoted answer in this similar thread: SQL Server query to find all permissions/access for all users in a database.
Best regards,
Cosmog
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".