Role of A user

Posted on 2011-02-16
Last Modified: 2012-06-27
Hi Guys,

In my SQL Server, i have Wilson as user. I need to know what is his role.

Could we have SQL syntax to check what role is wilson. Specifically I wanna know whether Wilson has role Sysadmin or not.

Question by:softbless
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 41

Accepted Solution

Sharath earned 500 total points
ID: 34913670
Can you check this?
SELECT AS [Login Name],
 SSP.type_desc AS [Login Type],
 UPPER( AS [Server Role]
FROM sys.server_principals SSP 
INNER JOIN sys.server_role_members SSRM
ON SSP.principal_id=SSRM.member_principal_id 
INNER JOIN sys.server_principals SSPS 
ON SSRM.role_principal_id = SSPS.principal_id

Open in new window


Author Comment

ID: 34913693
Hi Sharath,

Thanks for the fast response.

Your query return 1 row :

Does it mean that 'Wilson' is not SYSADMIN?

Expert Comment

ID: 34913709
this means that sa is the SYSADMIN
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 41

Assisted Solution

Sharath earned 500 total points
ID: 34913740
Do you have Wilson under Security -> Logins folder? Can you run this query also and see the result?
select rolename =, membername= from sys.server_role_members rm
join sys.server_principals rolep on rm.role_principal_id = rolep.principal_id
join sys.server_principals memp on rm.member_principal_id = memp.principal_id

Open in new window


Author Comment

ID: 34913783
Hi Sharath,

The result is :
rolename      membername
sysadmin      sa

LVL 41

Expert Comment

ID: 34913790
Can you check if Wilson is available under Security -> Logins?

Author Closing Comment

ID: 34976880

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question