Using the script above we could do something like this :
Select RMM.Grantee
, RMM.RoleName
, ARR.AccessRight
, ARR.Databasename
, ARR.Tablename
From DBC.RoleMembers RMM
Join DBC.AllRoleRights ARR
ON RMM.RoleName = ARR.RoleName
Where ARR.Databasename = '<dbname here>'
And (ARR.Tablename = 'All' or ARR.Tablename = '<tablename here>')
AND RMM.Grantee = '<userID here'
----------------- This catches the "ALL" case as well as the actual table name but may have a drawback as it allows for duplicates --------------------------------------
and to remove duplicates try this
Select distinct(RMM.RoleName), RMM.Grantee , ARR.AccessRight From DBC.RoleMembers RMMJoin DBC.AllRoleRights ARR
ON RMM.RoleName = ARR.RoleName
Where ARR.Databasename = '<DBname here>'
And (ARR.Tablename = 'All' or ARR.Tablename = '<TABLE NAME HERE>')
AND RMM.Grantee = '<USER ID HERE>'
- I know this is way late but it helps to share this info for the next person who needs it. Work smarter! Google it!
↧