Importing a MDF file into SQL Server 2008?

11,151

Solution 1

You need to get Sql Server Management Studio. From there you should be able to connect to the instance of Sql Server Express running on your system and tell it to attach to the .mdf file. This will allow you to use that database from withing sql server and management studio, and you will be able to add your stored procedure. Just remember to detach again when you're done, or you won't be able to use the mdf file as you expect from your app.

Solution 2

You can't attach mdf file made in SQL Server 2005 to a SQL Server 2008 instance. What you need is to install SQL Server 2005 Express, attach this file, backup database, then restore it on 2008 Server instance and detach the database. You will get properly created for 2008 Server mdf.

Solution 3

Visual Studio uses SMO 2005 to connec to to SQL. The SMO 2005 will not connect to SQL 2008 by design. You need to either upgrade VS to VS 2008, or downgrade Express to Express 2005.

Share:
11,151
DisgruntledGoat
Author by

DisgruntledGoat

I'm a web developer and programmer from the UK. I'll fill this out more when I can be bothered; really I'm just trying to get the autobiography badge.

Updated on June 04, 2022

Comments

  • DisgruntledGoat
    DisgruntledGoat almost 2 years

    I have inherited a VB.net web app that I'm making some changes on. I'm perfectly capable with the programming side (VB and MSSQL) but I'm getting lost with the tools. I was given a zip file of the code and everything. I opened the sln file in Visual Studio 2005 and it worked fairly easily with little modification.

    Running the app works perfectly. Problem is, I need to write some new SPs so need the database admin. SQL Server 2008 Express is installed but it doesn't see any database and I have no idea how to import it.

    I have a folder App_Data in the project with the file ASPNETDB.MDF. Opening this in VS gived the error:

    This server version is not supported. You must have Microsoft SQL Server 2005 Beta 2 or later.

    Any ideas where to go from here?

  • DisgruntledGoat
    DisgruntledGoat over 14 years
    Thanks, "Attach" is what I wanted. Weird I couldn't find that from searching, I think my Google is getting worse...
  • Nathan
    Nathan over 14 years
    I think this offers a way to upgrade Visual Studio 2005 to connect to SQL Server 2008. msdn.microsoft.com/en-us/library/cc440724.aspx
  • Remus Rusanu
    Remus Rusanu over 14 years
    @Nathan: Good info, I wasn't aware they provided a fix for VS 2005 too. Nice.
  • Nathan
    Nathan over 14 years
    Thanks Remus. I just got around my "Server version not supported" issue by installing that CTP.