January 14, 2012 at 1:45 pm
I found the use of Information_schema to see who has select to tables in a database but I need to see who has data_reader access in a SQL Server 2008 database and I cannot seem to figure out the query for that. Can someone help this?
January 14, 2012 at 5:40 pm
Markus this will get you started; this does a first level who's in which role; it does not handle nested roles, where eventually someone in a role, which is assigned the role, gets the permission:
select WhoAmI.name As UserOrRole,
RolesIOwn.name as InThisRole
from sys.database_role_members members
left outer join sys.database_principals WhoAmI
ON members.member_principal_id = WhoAmI.principal_id
left outer join sys.database_principals RolesIOwn
ON members.role_principal_id = RolesIOwn.principal_id
--where RolesIOwn.name = 'db_datareader'
Lowell
January 15, 2012 at 9:08 am
Thanks Lowell. WOrks like a charm!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply