Wednesday, June 30, 2010

Cannot access the database under current security context

Sometimes there will be situation where you are trying to access some database of trying to execute some stored procedures.
You may come across a error which states something like
“Unable to access the database [DatabaseName] under current security context”.
This error may occur if there are some issues with the permissions and if permissions are denied.
Using this query you can get the details of denied permissions and then you can resolve the issue by assigning proper permissions.

SELECT * FROM sys.server_permissions WHERE grantee_principal_id = 2 AND state = 'D'

No comments:

Post a Comment