Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query for Role

Author  Topic 

bobmcclellan
Starting Member

46 Posts

Posted - 2012-01-20 : 09:48:18
I need to check to see if a user
is in a specific role....
How would I query by login to see
what roles a user is a member of...
Thanks in advance,
..bob

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-01-24 : 20:32:15
Depending on which set of Roles you are interested in, there are a set of system tables that you can make use of:
sys.server_principals can be used to filter a set of Logins and a set of server Roles
sys.server_role_members will tell you which Logins are members of which server Roles
sys.database_principals can be used to get a set of database Users and Roles
sys.database_role_members will tell you which Users are members of which database Roles


=================================================
Men shout to avoid listening to one another. -Miguel de Unamuno
Go to Top of Page
   

- Advertisement -