I have a sql server user that our application is connecting as. The user has been granted db_datareader and db_datawriter as well as Grant Execute on each stored procedure that it needs to use.

These are the permissions I see when I veiw the usermapping on the Login and when I view the user under the database.

Given these permissions I don't think the user should be able to alter a procedure; however, when my developer logs in as that user they are able to update the stored procedures.

Am I wrong about what these permissions allow? Is there someplace I can look to find out about permissions that may not being showing up in the UI? Or do I need to explicitly deny alter on the stored procedures for that user?

2 Answers 2


Do you see anything that has been granted or role membership that shouldn't exist?

EXECUTE AS USER = N'your user';
SELECT * FROM sys.fn_my_permissions(NULL, NULL);

SELECT * FROM sys.database_permissions
WHERE grantee_principal_id = USER_ID(N'your user');

SELECT r.name
FROM sys.database_role_members AS m
INNER JOIN sys.database_principals AS p
ON m.member_principal_id = p.principal_id
INNER JOIN sys.database_principals AS r
ON m.role_principal_id = r.principal_id
WHERE p.name = N'your user';

SELECT r.name
FROM sys.server_role_members AS m
INNER JOIN sys.server_principals AS p
ON m.member_principal_id = p.principal_id
INNER JOIN sys.server_principals AS r
ON m.role_principal_id = r.principal_id
WHERE p.name = N'your login';

It is possible these developers are in the db_owner role without your knowledge or have been granted ALL on the dbo or another schema.

Make sure you execute these statements in the right database, and also validate that your users are logging in as who they say they are logging in as. Perhaps they have the sa password and you don't know it. Finally, you should make sure that the database principal maps to the correct server-level login.

SELECT dp.name, sp.name
FROM sys.database_principals AS dp
FULL OUTER JOIN sys.server_principals AS sp
ON dp.sid = sp.sid
  dp.type <> 'R' 
  OR sp.type NOT IN ('C', 'K')
  • Aaron thanks for the hand. fn_my_permissions returned an empty record set. The select query returned db_datareader and db_datawriter. They haven't been granted db_owner that I'm aware of and I'm not running any custom roles.
    – Lumpy
    Oct 3, 2012 at 19:44
  • What about sysadmin at the server level? I'll add a query to check server-level roles. Oct 3, 2012 at 20:12

I found it. It turns out there is a custom role that the user was added to, and that custom role had given the user access. Unfortunatly, that role didn't show up in the query above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.