List of Database Object Permissions

Posted: November 22, 2011 in SQL Server 2005

To find the nth maximum record, you can try the following:

SELECT o.name,
       user_name(dp.grantee_principal_id) grantee,
       user_name(dp.grantor_principal_id) grantor ,
       dp.permission_name ,
       dp.state_desc,
       o.type_desc
FROM   sys.database_permissions dp 
       INNER JOIN sys.objects   o  ON o.object_id = dp.major_id
                                  AND dp.class     = 1 
                                  AND o.type IN ('U', 'P', 'V', 'Fn') -- U(User Tables), P(Store Procedure), V(View), Fn(Function)
WHERE    dp.type IN ('SL', 'IN', 'UP', 'EX') -- SL(Select), IN(Insert), Up(Update), Ex(Execute)
ORDER BY o.type_desc, 
         o.name;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s