In SQL Server 2005, how do I display all permissions a user/login has? Is there a stored procedure to do this?
In SQL Server 2005, how do I display all permissions a user/login has? Is there a stored procedure to do this?

Software/Hardware used:
ASKED: March 4, 2008  11:36 PM
UPDATED: April 21, 2008  3:54 PM

Answer Wiki:
SQL Server includes a procedure which I'm not fond of. It's called sp_helprotect. However I've got some code which I've thrown together which will display this data nicely and in a single call instead of the mess of code within the procedure.
<pre>select sys.schemas.name 'Schema', sys.objects.name Object, sys.database_principals.name username, sys.database_permissions.type permissions_type,
sys.database_permissions.permission_name,
sys.database_permissions.state permission_state,
sys.database_permissions.state_desc,
state_desc + ' ' + permission_name + ' on ['+ sys.schemas.name + '].[' + sys.objects.name + '] to [' + sys.database_principals.name + ']' COLLATE LATIN1_General_CI_AS
from sys.database_permissions
join sys.objects on sys.database_permissions.major_id =
sys.objects.object_id
join sys.schemas on sys.objects.schema_id = sys.schemas.schema_id
join sys.database_principals on sys.database_permissions.grantee_principal_id =
sys.database_principals.principal_id
order by 1, 2, 3, 5</pre>
Last Wiki Answer Submitted:  April 19, 2013  2:34 pm  by  Michael Tidmarsh   11,390 pts.
All Answer Wiki Contributors:  Michael Tidmarsh   11,390 pts. , Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.

 64,520 pts.

 

Yes, you can use sp_helprotect procedure like suggested above.

You can also achieve this with a new version of enterprise security reporter that is already avialable as a beta at http://www.scriptlogic.com/beta

I’ve implemented this tool in our environment a while ago.
It does the job quite well inlcuding very powerful sql reporting abilities with a plenty of predefined reports.
In addition to the report that you are looking for, the tool includes reports on database object and schema permissions, effective database object permissions, database and server role membership, effective database and server role membership.

Hope this was useful!

 20 pts.