SQL Tips by Namwar Rizvi

May 28, 2007

Retreive current user permissions in SQL Server 2005

If you want to retrieve the permissions available for the currently logged in user then you can use the function called fn_my_permissions in SQL Server 2005. Following are examples of its usage:

Use AdventureWorks
Go

—Return Caller’s permission on the current server
SELECT * FROM fn_my_permissions(NULL, ‘SERVER’);
Go

—Return Caller’s permission on the current database
SELECT * FROM fn_my_permissions(NULL, ‘DATABASE’);
Go

—Return Caller’s permission on the given object
SELECT * FROM fn_my_permissions(‘Sales.vIndividualCustomer’, ‘OBJECT’);
Go

For further details please refer to Technet help here

Advertisements

2 Comments »

  1. Thanks for your nice tip.

    If you need a more advanced sql security reporting solution (for example, if you are preparing for compliance audit) I suggest you to have a look at new enterprise security reporter 3.6.
    It’s not out yet, but you can get a beta version from http://www.scriptlogic.com/beta like I did.
    The tool works great and includes very powerful discovering and reporting on sql server security.
    This enterprise security reporter supports sql server 2000 and 2005 versions, including msde and sql 2005 express.

    Comment by Jeremy Styles — April 10, 2008 @ 3:17 PM | Reply

  2. hi ,

    good post and easy to understand

    thanks
    bhaskar
    http://csharpektroncmssql.blogspot.com

    Comment by Rare Technical solutions — June 5, 2012 @ 8:10 AM | Reply


RSS feed for comments on this post. TrackBack URI

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

Create a free website or blog at WordPress.com.

%d bloggers like this: