Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a database on a SQL Sever 2012 instance which I would like to copy to a 2008 server. The 2008 server cannot restore backups created by a 2012 server (I have tried).

I cannot find any options in 2012 to create a 2008 compatible backup. Am I missing something?

Is there an easy way to export the schema and data to a version-agnostic format which I can then import into 2008?

The database does not use any 2012 specific features. It contains tables, data and stored procedures.

Here is what I have tried so far

I tried TasksGenerate Scripts on the 2012 server, and I was able to generate the schema (including stored procedures) as a SQL script. This didn't include any of the data, though.

After creating that schema on my 2008 machine, I was able to open the "Export Data" wizard on the 2012 machine, and after configuring the 2012 as source machine and the 2008 as target machine, I was presented with a list of tables which I could copy. I selected all my tables (300+), and clicked through the wizard. Unfortunately it spends ages generating its scripts, then fails with errors like "Failure inserting into the read-only column 'FOO_ID'".

I also tried the "Copy Database Wizard", which claimed to be able to copy "from 2000 or later to 2005 or later". It has two modes:

  1. "Detach and Attach", which failed with error:

    Message: Index was outside the bounds of the array.
    StackTrace:    at Microsoft.SqlServer.Management.Smo.PropertyBag.SetValue(Int32 index, Object value)
    ...
    at Microsoft.SqlServer.Management.Smo.DataFile.get_FileName()
    
  2. SQL Management Object Method which failed with error

    Cannot read property IsFileStream. This property is not available on SQL Server 7.0."

share|improve this question
Are you able to export direct? I don't know how big your DB is, but this is what I would do when working with smaller databases. – Dave Rook Aug 31 '12 at 9:52
1  
No older version of SQL Server can restore backups from newer versions. This is by design. Use the Export feature, script out the tables and the data, and set the script target to SQL 2008. – Randolph West Aug 31 '12 at 15:29
@RandolphWest - This only works if you have the ability to export the database. If you say did an export and didn't change the version of the script, then deleted the database, you would have to have course import it back to the same version then export it the correct way. Trying to figure out why anyone in their right mind would migrate backwards. – Ramhound Aug 31 '12 at 16:25
3  
"Trying to figure out why anyone in their right mind would migrate backwards." -- I have a production server running 2012, but my dev machine has only 2008. I'd like a local copy of the DB to aid development, but I don't want to install 2012 on my dev machine as I haven't that much free space left, and don't want to spend hours installing it. (So I'm spending hours trying to migrate backwards instead.... but that's just me.) – Rich Aug 31 '12 at 17:11
1  
You are almost there. The Export section you went into has an option to include data as well as the schema. – Randolph West Sep 2 '12 at 2:56
show 4 more comments

4 Answers

up vote 6 down vote accepted

Right click on the database in the 2012 SQL Management Studio, and choose "Tasks -> Generate Scripts". Click past the welcome screen, choose "script entire database and all database objects". On the "specify how scripts should be saved" page, click "advanced". Under "General" in the pop up properties page, change "Types of data to script" from "Schema only" to "Schema and data", and change "Script for Server Version" from "2012" to "2008".

I then had to find some way to edit the start of this massive SQL file, to tweak how the database would be created -- see this q: http://stackoverflow.com/questions/102829/best-free-text-editor-supporting-more-than-4gb-files

And finally I had to find some way to run the SQL script, which was too large to open in SQL Management Studio -- see this q: http://stackoverflow.com/questions/431913/how-do-you-run-a-300mb-ms-sql-sql-file

share|improve this answer

I'm new to SQL, but I managed to migrate from 2012 to 2008. To do so I used the SQL import and export utility. I chose the SQL 2012 server and the database I want to migrate and finally the 2008 server and created a new database as my database of destination. It worked.

share|improve this answer

Try APEXSQL tools. They have a tool that will script the database and script the data also.

share|improve this answer
"from $299" -- is there a free alternative? – Rich Sep 1 '12 at 6:54

After creating that schema on my 2008 machine, I was able to open the "Export Data" wizard on the 2012 machine, and after configuring the 2012 as source machine and the 2008 as target machine, I was presented with a list of tables which I could copy. I selected all my tables (300+), and clicked through the wizard. Unfortunately it spends ages generating its scripts, then fails with errors like "Failure inserting into the read-only column 'FOO_ID'".

The problem is that it is not able to insert the ID columns, so:

  1. Select all the tables by ticking them
  2. Select all the tables (the way to do this is click on the first one and hold shift and click on the last table)
  3. Click on "Edit Mappings" - you can see that just above the next button and next to preview .
  4. You will get a window, tick on the "Enable identity insert" and then click next and go ahead, this should work. It worked for me.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.