Counter of Festivals

Ashok Blog for SQL Learners and Beginners and Experts

Sunday 17 November 2013

The server principal "login" is not able to access the database "Database" under the current security context Resolved

The server principal "login" is not able to access the database "Database" under the current security context Resolved:

The Above Error should be get in our SQL server due to following scenarios

If the user have objects like SP,Views,UDF etc to Execute permission in only restricted Database but that SP code include user doesnt have Execute permission database.

Sample.

Below user have only Testdb Execute permission only  like user mapping see below:


but User have dont have permission on FoodManagement db see below


But user code include insert code in foodmanagement db see below



So when user execute SP he will get error like see below:

The server principal "User" is not able to access the database "FoodManagement" under the current security context.


To Avoid/Resolve:

Kindly map the missing FoodManagement db to that user then he can execute that sp without any error




No comments:

Post a Comment