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’
Advertisements

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