Just to remind me because I always forget about it
I was trying to do some maintenance on the SQL database that I use for one of my sites.
I used SQL Management Studio to connect ok but when I tried to expand the database container I got this error (with username and dbname being specific to your site)
The server principal "username" is not able to access the database "dbname" under the current security context.
.Net SqlClient Data Provider in SQL Server Management Studio.
It’s a shared hosting plan so obviously the security is pretty tight but I couldn’t even view my own database
Fortunately the answer is simple (I found the answer on lots of sites but this the first one i found –thanks!)
This is because the MS SQL Server is attempting to execute a T-SQL query to retrieve a list of databases along with additional information about those databases. One of those pieces of information is "Collation", which you will not have permission to action for all databases as you’re in a shared hosting environment and you only have access to your database alone.
Step 1: In Object Explorer, click Databases
Step 2: Display Object Explorer Details (F7) or View > Object Explorer Details
Step 3: Right click the column headers and de-select "Collation"
Step 4: Refresh Databases
Easy enough – once I’d stopped the collation field from displaying all was well