Solved

Database role member validation from Trigger or SP

Posted on 2014-09-08
3
243 Views
Last Modified: 2014-09-09
I Need to validate if a system user has the "Database Mail User role" in the msdb database but I need to call it from either a stored procedure or trigger from another database, and of course the USE [DATABASE] is not allowed in SP or triggers. If I execute  select IS_ROLEMEMBER ('DatabaseMailUserRole' ) as permission in the msdb database it works fine returning a 1 or 0. any help would be greatly appreciated.
0
Comment
Question by:skull52
  • 2
3 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 40310374
I take it you mean "IS_MEMBER"?

DECLARE @is_member bit
EXEC sp_executesql N'USE msdb; SELECT @is_member = IS_MEMBER(''DatabaseMailUserRole'')', N'@is_member bit OUTPUT', @is_member OUTPUT
--SELECT @is_member
0
 

Author Comment

by:skull52
ID: 40312463
Thanks Scott, that is exactly what I needed.
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 40312483
Great, glad it helped!
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Requesting help with creating an SQL query with 2 tables 6 31
SQL Recursion schedule 13 34
shrink table after huge delete 2 27
Duplicated data in GROUP_CONCAT 2 14
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…

679 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