Sql-server – Lost databases in SQL Server 2012

sql serversql-server-2012

Had three databases connected to SQL server 2012, unfortunately, now I can't see any of them under the Databases part of the tree in SQL Server Management Studio. The files (.mdf) are still on the disk, but when I try to reconnect them, I get this error once I click on the mdf file,

Failed to retreive data for this request (Microsoft.SqlServer.Management.Sdk.Sfc)
Additional information
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
The server principal "IESVE\user" is not able to access the database "model" under the current security context (Microsoft SQL Server, Error: 916)

I thought this might be a problem with the management studio, but when I try to connect via ADO, I get this error,
[DBNETLIB][ConnectionOpen(Invalid Instance())] Invalid Connection

All of this worked before and the only thing I can think of is a recent windows update.

If anyone's got any ideas on how to fix/diagnose this, I would be very grateful,
Thanks
James

Edit; Running as administrator gets me a bit closer to reattaching the databases, but now I have this error SQL error message . I'm wondering if my SQL server version has been downgraded, judging by that error message.

Thanks,
James

Best Answer

It looks like MS has seen this already. Have you tried running SSMS through Right Click - Run As Admin?

http://connect.microsoft.com/SQLServer/feedback/details/198005/not-able-to-access-the-database-model-under-the-current-security-context-microsoft-sql-server-error-916

Also are you logging in as a sysadmin to SQL Server? Do you have create DB rights?

Edit: Just saw your original post updated. It looks like you are restoring to the wrong version for sure. Consider yourself lucky if that is the issue!!

Do a SELECT @@SERVERNAME. What does it return? Is that the right instance? Probably not (hopefully). Try your restore script only after SELECT @@SERVERNAME returns the right info. Also you might want to use OSQL where you have to state the server name and creds before connecting, that way you know you're at the right one instance.