Solved

check database role

Posted on 2010-09-17
4
1,144 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 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

756 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