What are my permissions?

1

August 16, 2018 by Kenneth Fisher

Permissions are a common concern. One of the most frequent requests I get is I need X, Y and Z permissions. And all too often the conversation goes like this:

Dev: I need write permission to this database.
Me: Ok.
Me: Checks their current permissions.
Me: You already have that permission.
Dev: Oh, ok, thanks.

It would certainly make my life a lot easier if there was a way for people to check their own permissions. Oh wait, there is!

sys.fn_my_permissions

This handy dandy function will tell you what your effective permissions are for any given object. That means if you have SELECT permissions from one role, and INSERT from another then this will show that you have SELECT, INSERT permissions. Note: It does not tell you where those permissions come from. Just what you have.

Now, I said object. That object, among other things, could be a database object (sp, table, etc), schema, the server, or even a database. See the link above for the full list. The syntax is pretty simple:

SELECT * FROM sys.fn_my_permissions(‘[object name]’,'[object type]’)

Example using the system view sys.tables

SELECT * FROM sys.fn_my_permissions('sys.tables','object');

Last comment on this. I usually have sysadmin permissions so I have all the permissions, so why would I ever need to use this? One word.

Impersonation

If you impersonate someone, you can then use this same system function to look at their effective permissions. Which in the end, is one of the easiest/fastest ways to check permissions for a specific object. (See the conversation above.)

One thought on “What are my permissions?

  1. Kevin Fries AKA Cujo says:

    Love this! Thanks again.

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 3,755 other subscribers

Follow me on Twitter

ToadWorld Pro of the Month November 2013
%d bloggers like this: