Monday 6 April 2009

*.MDF' cannot be opened because it is version 655. This server supports version 612 and earlier

When I'm not playing with Silverlight and Virtual Earth, I've been figuring out MVC (thanks to Scott, Scott and Phil). However pretty early on I hit a weird error in Visual Studio 2008 when trying to 'open' a database via the Server Explorer:

The database 'C:\SOME\FOLDER\MYDATABASE.MDF' cannot be opened because it is version 655. This server supports version 612 and earlier. A downgrade path is not supported.

Background

I had created that database in Visual Studio 2008 (File → Add New Item → SQL Server Database) and now it wouldn't let me open it!

What I had done is opened, edited and closed the database file using SQL Server 2008 Management Studio. Shouldn't be a problem, right, since I'm also using Visual Studio 2008?

The Problem

Well, although I currently have SQL Server 2008 installed, I also have SQL Server 2005 (which was installed with Visual Studio 2008 originally). When I created the database originally I just assumed it was a SQL Server 2008 database - but it wasn't (it was 2005)!

Turns out that when you are create or open a file-based (.MDF) database (as opposed to using a database instance or server connection) Visual Studio needs some 'help' knowing what tools to use.

When I edited the *.MDF file in SQL Server 2008, it made some fundamental "changes" to the file (even though I didn't 'upgrade' it) which prevented SQL Server 2005 from opening it. Why was Visual Studio 2008 confused? It's a configuration setting!

To fix the problem, go to Tools → Options... → Database Tools → Data Connections and change the SQL Server Instance Name from whatever it was (probably a SQL Server 2005 instance) to your SQL Server 2008 instance, hit OK and you should be fine!





Thanks to simple-talk; and SQL 2008 Express edition error/Add new item on ASP.NET forms. A bit OT - HTH someone...

34 comments:

  1. I am having this same problem working on my senior project. Am using VS2008 and have created an SQL database in VS which I connect to. However when I take it to the lab I get this same kind of error. Do you think I can 'downgrade' to the SQL2005 like you are doing above? In my 'connection options' window my field shows SQLEXPRESS. From what it shows above I should be able to do this, just wondered if you think so.

    ReplyDelete
    Replies
    1. HI I FOUND YOUR ERROR DONT CHANGE SQL2008 JUST CHANGE YOUR SERVER NAME(NAME INSTANCE).
      WHICH NAME YOU TYPE WHEN INSTALL SQL SERVER THAT IS THE NAME INSTANCE

      Delete
    2. You can see the following article : https://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/

      As I have resolved same issue.

      Delete
  2. No, you cannot downgrade (the Microsoft documentation specifically says this).

    The instance name SQLEXPRESS could be either 2005 or 2008, so that doesn't really help you.

    I am not 'downgrading' my database, I am "telling" VisualStudio to use the 2008 'instance' to communicate with the MDF.

    The MDF file that you are creating at home and taking to the lab will either be in 2005 or 2008 format. If your lab at school only supports 2005 then you will need to have SQL Server 2005 (or 2005 Express) installed at home, and have THAT instance name showing in the dialog 'above'.

    ReplyDelete
    Replies
    1. Hi,
      while attaching the database in sqlserver2008 to vs2010 ,Im getting the error message.Will you please tell me the solution
      TITLE: Microsoft SQL Server Management Studio
      ------------------------------

      Attach database failed for Server 'PREETHI\SQLEXPRESS'. (Microsoft.SqlServer.Smo)

      An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

      ------------------------------

      The database 'EmployeeDB' cannot be opened because it is version 655. This server supports version 612 and earlier. A downgrade path is not supported.
      Could not open new database 'EmployeeDB'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)

      Delete
  3. my dear
    I have same as this problem >

    but > How I know the name of my SQL SERVER 2008 ?
    may be it is the problem .
    thanx

    ReplyDelete
  4. Look in Administrative Tools -- Services

    The 'default' SQL Server instance will be listed as
    SQL Server (MSSQLSERVER)and can usually be referenced by (local)

    Any other named instances (eg. a new 2008 install) will have a different name (which you would have typed/agreed to during install!)
    SQL Server (SQL2008) -- I chose SQL2008 as my instance name: yours could be anything.

    ReplyDelete
  5. thanx my dear:
    but Now I know what was the problem.
    when I was installing the visual studio with it directly installed the SQL Server 2005 and it became the Local Server on my Computer.
    and I have SQL SERVER MANAGEMENT 2008 .
    I went directly to (add and remove programs) and I deleted the SQL Server 2005 (Local)
    my computer Now becames without Local Server
    What can I do?
    I want to get Local Server 2008 or 2007 > but I cannt find it
    can you help me please ?
    thanx

    ReplyDelete
  6. Sorry Meshal, I'm happy to try and help but I cannot provide SQL Server Support - sounds like you need to contact Microsoft.

    I'm not sure why you deleted SQL Server 2005. I explained in my previous message how to find out the instance name of other SQL Servers on your computer by looking in the Services window.

    Perhaps you should re-install SQL Server 2008 (the Express version is free and can be downloaded from Microsoft).

    Good luck!

    ReplyDelete
  7. Thank you so much for this. I was having the exact same problem: Created in VS, edited in SQLExpress 2008, couldn't work with it in VS.

    Kudos!

    ReplyDelete
  8. Hi,

    I had the same issue as you, but in a different sequence
    - installed VS2008
    - open the .mdf file using VS2008 alone
    - installed SQL Server 2008
    - open the .mdf file using SQL Server 2008
    - tried to open the .mdf file using VS2008 and got the error msg

    I've already changed the Server Instance Name to both "SQLEXPRESS" and "MSSQLSERVER" but both don't work. I didn't change anything during the installation, so most likely it should be either one. What can I do to resolve this issue? Thanks.

    ReplyDelete
  9. @PeakTooSoon, trying those random names is only going to work by luck. Open your Services list from Administrative Tools and have a look at *exactly* what your instance names are. Then choose the 'correct' one (ie. SQL Server 2008 - look at the Service-Properties path to figure that out) and set up Visual Studio as above.
    That's really the ony advice I can provide - it *should* work...

    ReplyDelete
  10. Hi Craig,

    I've checked my services and I found 2 services with the names "SQL Server(MSSQLSERVER)" and "SQL Server (SQLEXPRESS)" without any indication which one's 2005 or 2008. Other than that, I can't find any other services that resembles an SQL Server.

    ReplyDelete
  11. In Services, right-click on the SQL Server() rows and look at the "Path to executable"... somewhere in the path you should see some indication of the version, eg MSSQL probably means 2005, MSSQL10 means 2008.
    Good luck. Otherwise maybe it's a different problem.

    ReplyDelete
  12. Hi Craig,
    Found your blog 2 b quite praiseworthy. However, the problem is the other way around. I created a database at office via SQL Server Mgt Studio.
    I copied the files MICAS.mdf & MICAS.ldf brought the same home on a disk. Copied on my personal laptop with Vista Home Premium + VS2008(SP1) + SQL Server Mgt Studio at home gives the same error, although I have changed the instance name from SQLEXPRESS to SQLFARAZ as found both names in services.
    Whereas VS2008 had no role in creating it?
    Furthermore, even when I use the SSMA to convert a Access Database to SQL 2008 it comes up with the error You must connect to an instance of SQL Server 2008.

    ReplyDelete
  13. Hi, Craig Dunn mentioned going into Administrative Tools to see what your 'instance' names are. (that post is over a year old). Where is this Adminisrative Tools? Is it in VS or Sql server? or maybe Windows? I'd like to give that a try since nothing else is working.
    I'm talking about the version 655 vs 612 problem

    Thanks

    ReplyDelete
  14. "Administrative Tools" is a Windows feature. It should be available in "Control Panel" (on the Start menu).

    ReplyDelete
  15. Problem resolved only after uninstalling and reinstalling the SQL Server's latest version

    ReplyDelete
  16. Thanks Craig

    ReplyDelete
  17. Faraz,

    What version of SQL server do you have, and are you talking about the 612 vs 655 problem?

    Thanks

    ReplyDelete
  18. I have two versions of SQL Server too (2005 and 2008) and had the same problem.

    In Tools → Options... → Database Tools → Data Connections I changed the SQL Server Instance Name to blank so my database opened without any problems.

    ReplyDelete
  19. Thank you for this, very succinct solution to my problem.

    ReplyDelete
  20. Thanks a lot, your post was the perfect solution.

    ReplyDelete
  21. I Craig, i have a question. how do i know if i have sql2008 installed.
    because, when i go to the starbar->all programs, all i see is microsoft sql server 2005. Also, i did that thing on Services, and all i see is this: "c:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe" -sSQLEXPRESS

    how can i know if i have 2008? And if a dont have, should i uninstall 2005 and instal 2008?

    ReplyDelete
  22. @Aquiteste Sounds like you probably have SQL Server 2005. You could try 'right-click > Properties' on that file from Services and see the version:

    8 = SQL Server 2000
    9 = SQL Server 2005
    10 = SQL Server 2008

    >>should i uninstall 2005 and instal 2008?
    I can't really answer that for you, it will depend on your needs.

    ReplyDelete
    Replies
    1. I m having the problem of SQL server.
      The database cannot be opened because it is version 655. This server supports version 612 and earlier.
      Please tell me what to do??
      Instance Name is -- SQLEXPRESS

      Delete
  23. Ok Craig,i'll do that. thanks for helping me.

    ReplyDelete
  24. Very helpful! I ended up installing separate instances of 2005, 2008 R2 and 2012 because I support a bunch of different versions.

    Thanks!

    ReplyDelete
  25. Thanks you so VERY much.

    ReplyDelete
  26. Thanks Craig, this solved my problem too (while trialling Nerd Dinner for AWS).

    ReplyDelete
  27. I need to create a database SQLSERVER 2005 from Visualstudio 2010, I have sql server express 2005 installed and i choose the instance of it in the database options, when i try to create the database Visualstudio Throws an error.

    ReplyDelete
  28. The database 'C:\USERS\ADMIN\DESKTOP\DESKTOP ICONS\ONLINE SHOPPING CART ASP.NET WEBFORM\C#\MYPROJECT\APP_DATA\SHOPING.MDF' cannot be opened because it is version 661. This server supports version 655 and earlier. A downgrade path is not supported.
    Could not open new database 'C:\USERS\ADMIN\DESKTOP\DESKTOP ICONS\ONLINE SHOPPING CART ASP.NET WEBFORM\C#\MYPROJECT\APP_DATA\SHOPING.MDF'. CREATE DATABASE is aborted.
    An attempt to attach an auto-named database for file C:\Users\Admin\Desktop\desktop icons\Online Shopping Cart Asp.Net WebForm\C#\MyProject\App_Data\shoping.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

    please help me fix this ....thanks

    ReplyDelete
  29. Dear All!

    Just reinstall all programs starting ms sql and hopefully the problem will be fixed. Worked for me!

    Regards,
    AAP

    ReplyDelete
  30. The database 'C:\USERS\APEKSHA\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\ALUMIN MEET\APP_DATA\ALUMIN.MDF' cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported.
    Could not open new database 'C:\USERS\APEKSHA\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\ALUMIN MEET\APP_DATA\ALUMIN.MDF'. CREATE DATABASE is aborted.
    An attempt to attach an auto-named database for file C:\Users\APEKSHA\Documents\Visual Studio 2010\Projects\alumin meet\App_Data\alumin.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.




    plz help me to fix this......

    Thanks

    ReplyDelete

Note: only a member of this blog may post a comment.