SQLServer: View Database User Permissions

Source: Internet
Author: User
1. view the database role useyourdbgoselectDbRoleg. name, MemberNameu. name, MemberSIDu. sidfromsys. database_principalsu, sys. database_principalsg, sys. Role

1. view SQL 2005 database role use yourdb go select DbRole = g. name, MemberName = u. name, MemberSID = u. sid from sys. database_principals u, sys. database_principals g, sys. database_role_members m where g. principal_id = m. role_principal

1. view the database role of the SQL 2005 user
Use yourdb
Go

Select DbRole = g. name, MemberName = u. name, MemberSID = u. sid
From sys. database_principals u, sys. database_principals g, sys. database_role_members m
Where g. principal_id = m. role_principal_id
And u. principal_id = m. member_principal_id
Order by 1, 2
Go

2. view the server role of the SQL 2005 Logon account
Use master
Go

Select SrvRole = g. name, MemberName = u. name, MemberSID = u. sid
From sys. server_principals u, sys. server_principals g, sys. server_role_members m
Where g. principal_id = m. role_principal_id
And u. principal_id = m. member_principal_id
Order by 1, 2
Go

3. view the permissions granted to SQL 2005 users
Use yourdb
Go

Exec sp_helprotect @ username = 'user name'
Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.