Sunday , December 22 2024

The server principal “login_name” is not able to access the database “database_name” under the current security context.

 

ERROR MESAGGE:

“The server principal “login_name” is not able to access the database “database_name” under the current security context.”

EXPLANATION:

You receive this error when you do not have sufficient privileges in the database that you are trying to access.

SOLUTION:

Make sure that the Login you connect to SQL Server Instance has sufficient privileges to access the relavant database.

 

You can follow these steps:
– Run SQL Server Management Studio.
– Connect to the related SQL Server Instance with a user account that can modify Login.
– Expand the Logins under the Security to find the corresponding Login and right click on this login and then click Properties.
– Click User Mapping and select the database you want to give the access right to the login from “Users mapped to this login” list.

In the screenshot below, we will map the login  named test to the database AdventureWorks.

 

or you can use T-SQL code as follows:

Loading

About Ekrem Önsoy

The original article was written in Turkish by Ekrem Önsoy and translated to English by dbtut with the consent of the author. The copyright of the article belongs to the author. The author shall not be liable in any way for any defect caused by translation.

Leave a Reply

Your email address will not be published. Required fields are marked *