SQL Server: View Database User Permissions

Source: Internet
Author: User

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
 

Related Article

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.