Thursday, December 18, 2014

Error "916".. Server Principal "Login_name" is not able to access the database "database_name" under the current security context...

I got a call from one of my colleague from another project saying that he is able to connect to server but not able to expand the database. While trying to expand database an error "server principal "Login_name" is not able to access the database "database_name" under the current security context" is coming  with error number 916." is coming.

I asked him to send the screen shot for same. Until I received the screen shot I thought he is getting error while clicking on particular database. So first thing which came to my mind was may be he don't have permission to access that database. I was having admin rights to his server so I connected to SQL Server with SA account and found that he already has required access rights on that database. 

I checked his mail and looking at screen shot I found that he is not able to expand the database tab not "particular database". Below is the screen shot 



As last year I had already worked on same issue so I was having clear idea about this but this was not documented in blog post so thought to do so.

Here are few reasons because of that you can get SQL Server Error 916:

1: A login does not have permission to view data of a column selected in the header
2: A database is offline and/or its collation is NULL
3: Multiple databases with different collations are on the instance and SSMS is unable to retrieve the collation because a database is configured to auto-close

In my case the reason was 3rd point "unable to retrieve the collation because a database is configured to auto-close".

If you want more information about "Auto_close" option Please click on below link.

Database Auto options in sql server

In my case they are using Sql server express Edition and Auto_close option is set to "True" by default in express Edition.To solve this problem One thing you can do is that change the Auto_close option to False. If not then follow the below steps:

1: Open SSMS and connect it.
2: Open Object Explorer Details window by clicking on “View” in the Menu bar –> 
            Select “Object Explorer Details” in menu (Or Just Press F7)
3: In Object Explorer window just click at Databases folder
4: In Object Explorer Details window right-click at the column header and uncheck “Collation”
5: Refresh Databases folder in Object Explorer.




I performed the above steps on server and the problem was solved.  


Thanks For Reading this Blog!!!





2 comments:

  1. Nice explanation, thanks for sharing with us, it helps me a lot. I have found another post regarding the same error. Here's a link: - http://www.sqlserverlogexplorer.com/fix-error-code-916/

    ReplyDelete