Solved

check database role

Posted on 2010-09-17
4
1,117 Views
Last Modified: 2012-05-10
like IS_SRVROLEMEMBER helped to verify a server role, is there an equivalent for database role?

thanks
0
Comment
Question by:anushahanna
  • 2
  • 2
4 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 33702034

SELECT is_rolemember('ROLENAME','USERNAME')


ex.
SELECT is_rolemember('db_owner','USERNAME')
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33702110
Brandon

is my format any issue..

all of these are returning NULLs

use tracker
SELECT is_rolemember('db_owner','USERNAME') -- your example
SELECT is_rolemember('db_owner','SRBSV\jimw') -- Domain User Group
SELECT is_rolemember('db_owner','tracker_Dev_Users') --SQL Login
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 500 total points
ID: 33702217
Is USERNAME a user in the SQL database?
Is SRBSV\jimw a user in the SQL database?
Is tracker_DEV_users a user in the database?

This script will show you the full mapping in each DB.

SELECT su.name,sr.name, is_rolemember(sr.name,su.name) 'is_RoleMember'
FROM sysusers su
  CROSS JOIN sysusers sr
WHERE su.islogin=1
  AND sr.issqlrole=1
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33702443
got it.

thanks Brandon.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

943 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now