Restoring SQL 2008 R2 db on SQL 2008 Standard - sql-server-2008

I'm trying to take a SQL Server 2008 R2 Expression db and restore it on my local SQL Server 2008 standard, however it gives me the error:
The media family on device 'C:\jtoth\Backups\ucampus.bak' is incorrectly formed. SQL Server cannot process this media family.
R2 is version 660 and standard is 655 and I know that you can't restore to an older version, but there has to be some way around this. Is there some free tool for scripting out the entire R2 database (including not just structure but inserts for the data) that I can then run on my standard instance?

Normally one of
SSIS (via the import/export wizard)
3rd party tool from Red Gate or similar.

You're right that the backup cannot be restored. See: SQL Server 2008 R2 bumps the database version. Your best bet would probably be the Red-Gate compare tools.

Use the Copy Database Wizard!, the Copy Database Wizard lets you move or copy databases and their objects easily from one server to another.

In SQL Server Management Studio, right click on the database, choose Tasks, then "Generate Scripts". Options in there to generate full scripts including the table structure and all the data. Additionally you can choose which version to script for.

Visual Studio has a Database Compare tool. Might be handy. See the Data menu. Not as good as 3rd party tools though..

Just an idea - how about changing compatibility level to SQL Server 2005 before backup? That is of course if nothing 2008 specific was used.

Related

How to attach database in SQL Server 2008 which was created in SQL Server 2012

I have two database files named as .mdf and .ldf which are created in SQL Server 2012 and now on my pc I installed Visual Studio 2010 and SQL Server 2008 Express.
When I try to attach these database files to SQL Server 2008 it gives me error.
The database 'C:\PROGRAM FILES\MICROSOFT SQL
SERVER\MSSQL10.SQLEXPRESS\MSSQL\DATA\CMS_DB.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:\PROGRAM FILES\MICROSOFT SQL
SERVER\MSSQL10.SQLEXPRESS\MSSQL\DATA\CMS_DB.MDF'. CREATE
DATABASE is aborted.
An attempt to attach an auto-named database for file C:\Program
Files\Microsoft SQL
Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\CMD_DB.mdf failed. A
database with the same name exists, or specified file cannot be opened,
or it is located on UNC share.
When open database in ssms 2008 then error :
Attach database failed for Server 'MATRIX-PC\SQLEXPRESS'. (Microsoft.SqlServer.Smo)
Additional information:
An exception occured while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
The database 'C:\USERS\RAJ\DESKTOP\COLLEGE MANAGEMENT SYSTEM(.NET 4.5)\ COLLEGE MANAGEMENT SYSTEM\BIN\DEBUG\CMD_DB.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\RAJ\DESKTOP\COLLEGE MANAGEMENT SYSTEM(.NET 4.5)\COLLEGE MANAGEMENT SYSTEM\BIN\DEBUG\CMD_DB.MDF'. CREATE DATABASE is aborted.
(Microsoft SQL Server, Error: 948)
No, you can only move forward.
This means, you can restore the database from 2005 or 2008 to 2012 version but can not do it in reverse order. The next most popular question I receive is if we can’t restore a SQL Server 2012 database to earlier version what is the next best option?
I have personally faced this issue once before and I had manually created T-SQL script using Script and Data Generator Wizard in SQL Server 2012 and rebuild my database in
SQL Server 2008R2. If you have many different databases which you want to address, you can use SSIS to
automate the script generation.
As noted if you want to access a 2012 db from 2008 you will have to migrate the database back to 2008. This will only be possible if you have not used 2012-specific features in the db. If you have and still want to perform the migration you should first try and identify these where they occur and fix those first.
As noted above one option is to generate T-SQL scripts and use these to regenerate the db in 2008. However for a large db this could be time consuming and hard work to get to actually work.
A better option than using the SSMS scripting wizard is to use a similar tool available on Codeplex called SQL Database Migration Wizard - http://sqlazuremw.codeplex.com/releases/view/32334. You want the latest version v4.x to work with SQL Server 2012.
The tool is originally intended to be used for migrating databases between SQL Server and Azure. However the tool works just as well between SQL Server 2012 and SQL Server 2008. The trick is to set SQL Server rather than Azure as the target in the advanced options.
The reason this is a better option than the SSMS scripting wizard is that it uses BCP for the data transfer rather than TSQL and so is much more efficient. I migrated a 7GB database in about 2 hours with this with most of the time spent drinking tea while the machine worked away. Importantly, it all just worked with no requirement for me to start editing files to fix problems like too many commands, timeouts etc.

Is it possible to export a database from SQL Server 2008 and import it into SQL Server 2005?

I need to move a database from SQL Server 2008 to 2005, did the backup format changed or can I import the exported DB in the SQL Server 2005?
The database has tables, views and stored procedures, and it is not using any 2008 specific features.
If it's not possible, would setting the compatibility mode to SQL-Server 2005 (90) help in this case?
Thank you.
Select your database in SSMS, right-click, select Tasks, select Generate Scripts. In the dialog box that pops-up, enable all options, including script data and make sure you select "Script for SQL Server 2005". Execute the generated scripts on your SQL Server 2005 machine. This is workable only for a relatively small database, of course. Else, you'll have to export/import data via bcp.
You won't be able to do this - the backup file contains a version number, and SQL 2005 will refuse to restore the backup. Similarly, you won't be able to detach and reattach the raw data files.
The only option you have, short of upgrading SQL 2005 to 2008, is to export the SQL schema and sprocs using SSMS's ability to generate scripts, and then migrate the data using (for example) BCP or an SSIS package.
There will be third party tools that might be able to help with some of this (for example, a combination of Redgate's SQL Compare and SQL Data Compare). However this is something you will have to research.

Convert MSSQL2008 *.bak file to SQL-CE *.sdf

I wish to convert data from an mssql2008 .bak (or out from a running 2008 server) to sql-ce's *.sdf for use in a webmatrix project. I have SQL Server Management Studio 2008 R2 installed as well.
There is no tool that will directly convert a bak to an sdf.
You're going to have to restore it to a functional SQL Server Engine of the same (or newer) version and then script it out. That's how I'd do it anyway. Also keep in mind that you're not going to be able to use the views, stored procs, triggers, etc, if there are any in the database contained in the .bak file.
There was a codeproject effort with SQL 2005 to create a utility that would help with the conversion from a full blown database to a ce database. You can check it out here:
http://www.codeproject.com/KB/database/SqlCompactCoptUtility.aspx
For help with scripting start here:
http://msdn.microsoft.com/en-us/library/ms178078.aspx
Or to just dive right in: Right-click a database, point to Tasks, and then click Generate Scripts. That will bring up a wizard with all sorts of options to help you get the tables and data moved.

Downgrade SQL Server 2008 r2 to SQL Server 2008

I need to upload a .bak file to SQL Server. How can I downgrade the database from SQL Server 2008 R2 to SQL Server 2008
thanks
You cannot. Period. That's never been possible with SQL Server (and most likely never will be).
If you have a database backup file from a 2008 R2 version, you cannot under any circumstances and with any tricks or tools restore that into a 2008 version. Just cannot be done.
You need to either find a way to do this using scripting (e.g. script out the SQL structure and/or data), or you could use a structure/data comparison tool like Red-Gate SQL Compare and Red-Gate SQL Data Compare to compare two databases. With Red-Gate's tools, you can also compare a live 2008 database against a 2008 R2 backup file and move data between them.
We can generate scripts and we run them in lower version.
steps to do this.
STEP 1: Right click database which you want to downgrade.you will see option to script that. in advanced section choose for which version you want to downgrade.
STEP 2: This will script your databse.
STEP 3: Copy the script on other machine and run following command.
SQLCMD -S LOCALHOST -d <databse_name> -i <scriptpath/name> –E
This link might help you more.

Error migrating from Access 2007 database to 64-bit SQL Server 2008

I am using 64-bit Vista and I need to migrate an access database, in Office 2007 to SQL Server.
I don't want to have to write an SSIS package to do this, but that may be my only option.
Is there any other way to do this? I have about 330M of data in Access that needs to be moved, so I can write a webapp to replace this database.
Update: The error is:
The upsizing Wizard does not work with the version of Microsoft SQL Server to which your Access project is connected. See the Microsoft Office Update Web site for the latest information and downloads.
In Access, use the upsizing wizard under tools menu...
Edit, checked to see if it's still there: it has issues with SQL Server 2008.
Do you get the same error? (yes you do, says your edit)
Alternative: SSMS/Migration for Microsoft Access
See if creating a Linked Table inside Access DB (which points to your destination table in SQL Server) helps.
OR
See if you can use SQL Server functions (such as OPENROWSET) to open the Access tables.
The SQL Server 2008 Import/Export tool has worked great for me for migrating tables as well as data. You may need to install the SQL Management Studio to get the import tool also (it'll show up in your Start menu). It supports moving tables/data around from various sources, and I'm guessing that Access 2007 is supported.
That said, the SSMS/Migration for Microsoft Access tool may work the best overall.
Best of luck.
When all else fails, you could try creating an ODBC DSN for your SQL Server and then export the tables to that DSN. It won't get all the datatypes right, but it might be good enough to get things started if nothing else works.
I think it's pretty amazing that you can export a Jet/ACE table to an ODBC data source, to be honest.