This will work for users who receive permissions as part of role membership as well as direct permissions on an object.
--this WILL work for role based permissions as well.
select b.name + '.' + a.name, permissions.permission_name from sys.tables a
inner join sys.schemas b on a.schema_id=b.schema_id
cross apply (select * From fn_my_permissions(b.name + '.' + a.name, 'object') where permission_name='select' and subentity_name ='') as permissions
where a.type='u'
--should only have execute
select b.name + '.' + a.name, permissions.permission_name from sys.procedures a
inner join sys.schemas b on a.schema_id=b.schema_id
cross apply (select * From fn_my_permissions(b.name + '.' + a.name, 'object') ) as permissions
This blog has a lot of good information, very helpful. Katia
ReplyDelete