Find out the permission of the Current Connected User on the database using SQL Server 2005/2008

If you want to find out the permissions of the Current Connected Principal User on the database, then here's how to do so:

SELECT permission_name as Allowed

FROM fn_my_permissions('NORTHWIND', 'DATABASE')

The fn_my_permissions system function returns a list of the permissions effectively granted to the principal on a securable, in our case, the database Northwind. So running the query shown above, will display the permission of the current connected principal

Similarly to view permissions of the principal on a specific table, use this query

SELECT permission_name as Allowed

FROM fn_my_permissions('dbo.Employees', 'object')

If you want to view the permissions of a different principal user, use


and then execute the query.

About The Author

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and a new one recently at The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigous Microsoft MVP award for nine times in a row now. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that represents premium web sites and digital publications comprising of Professional web, windows, mobile and cloud developers, technical managers, and architects.

Get in touch with him on Twitter @suprotimagarwal, LinkedIn or befriend him on Facebook

No comments: