Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

check database role

Posted on 2010-09-17
4
Medium Priority
?
1,217 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
[X]
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
  • 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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

604 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