Error Opening .mdf's in MSSMS

Using Win7 Pro,  I've got several .mdf's that were originally created as part of an ASP.NET application in SQL Server Express 2005, under VS2005.  

I upgraded to VS2012, and to SQL Server 2012 EXPRESS.   The instance of SQL running on my machine now is  MSSQL11.SQLEXPRESS / 11.0.2218 RTM.  

During the upgrade, I did nothing to the the .mdf files.  

The application works fine under VS2012 and SQL 2012 Express;  there was very little code or configuration file change required.

I can open the .mdf's using the Server function in either VS2012 or VS2010 Shell, run queries, update the tables, modify/add tables, etc.

However, when I try to attach any of these .mdf's using MSSMS (this version)

Microsoft SQL Server Management Studio	11.0.2100.60
Microsoft Data Access Components (MDAC)	6.1.7601.17514
Microsoft MSXML						3.0 4.0 6.0
Microsoft Internet Explorer				9.10.9200.16686
Microsoft .NET Framework				4.0.30319.18052
Operating System						6.1.7601

I get "Error occurred while attaching.....  Click on hyperlink in message column"   but there's no hyperlink in the message column.

Any suggestions on what to do about this would be appreciated.

Who is Participating?
Vadim RappConnect With a Mentor Commented:
You definitely need to find out what is the actual error. means several possible causes for this problem, one is "access denied" for the file, another inconsistency between mdf and log file. To look into #1, you can run Process Monitor and see if there's any "access denied" when monitoring i/o access.

Look in the event log, perhaps the error is there. You can also look in the log of sql server you try to attach the mdf to.
Tapan PattanaikSenior EngineerCommented:
Hi codequest,

How to: Upgrade to LocalDB or Continue with SQL Server Express:

Upgrading SQL Server 2005 Express to 2008 R2 Express (for Backup Exec 2012) :

Supported Version and Edition Upgrades:

How to: Upgrade a SQL Server Express Report Server to Another SQL Server Edition:
codequestAuthor Commented:
@ tapanpattanaik

Thanks for the inputs.  Unfortunately I'm not able to translate those into an action plan.

Maybe I'm not understanding what's going on.  The information above is about upgrading servers.   However, I've already got SQL 2012 Express set up, and it seems to be able to access the .mdf's built in SQL 2005 Express.  

==> However, the issue is that I can't attach the .mdf's using MS SQL Server Management Studio 2012.    

Because I can attach the files SQL 2012 Express through Visual Studio 2012 and 2010, it doesn't seem like there's a problem with the .mdf's.  Is there?  

==> Do the .mdf's have to be converted in some way?
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

x-menIT super heroCommented:
try backup the databases on 2005, and restore on 2012
codequestAuthor Commented:
Per guidance from vadminrapp1:

I looked at the error in the log:  "access denied".  The link in the vadminrapp1 post said check the file permissions.  Gave the .mdf files full permissions for all users (my personal machine), and the files opened up fine in MSSMS.

Thanks much!
Vadim RappCommented:
We suggest that you now remove full permissions for everyone from the mdf files. The required permissions (which is full permisions for the database engine's service account only) should have been set by sql server when you attached them.  More in the article "Securing Data and Log Files" .
codequestAuthor Commented:
Thanks for the input.   I mis-spoke.  I'm not adding "everyone".

I'm adding "Users (computername\Users).

After I hit "apply", and then attach the .mdf (which then works), the permissions shows not "Users (computername\Users)", but "MSSQL$SQLEXPRESS"

Is that the behavior you were referring to?
Vadim RappCommented:
Yes. If "users" is no longer there, it means that not only it added service account for itself (MSSQL$SQLEXPRESS), but also did what I suggested - deleted the permissions for others.
codequestAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.