restore a sqlserver 2005 database into sqlserver 2012 - sql-server

I have a db running on an instance of sqlserver 2003, Ive tried to import it into sqlserver 2012 but that wont work it's says it's to old.
so I've imported it into sqlserver 2005, I have then backed it up again and tried to import it into sqlserver 2012 but it comes up with the same error.
I can restore other db's from sqlserver 2005 so I can only presume its keeping its 2003 settings when I back it up.
Can anyone help

I suspect that your database might have some deprecated functionality that prevents your upgrade from working.
There's a list of deprecated functionality between SQL Server 2000 and SQL Server 2005 on technet.
I would strongly advise you to use the SQL Server 2005 Upgrade Advisor to identify such functionality, and address any potential issues. Then, and only then you should have a database compatible with SQL Server 2005, and can (hopefully) proceed from there.

if u want database structure only then take database script then run into sql server 2005, if u want database with data also mean
right click the Database go task
click Generate Script
There Two options entire database or with specific objects
entire database for DataBase structure only
with specific objects - select all objects then click Next you find the Advance button then click it.
scroll down and Find Type of Data Scripts click and change to Schema and data then you will save as file file or new query window
this is one of the method to restore the database.

Set your compatibility level to (90) Sql server 2005 in your database properties after restoring.

Related

How to export the localDb to an online Sql Server Database?

I used visual studio 2013 for developing a web application and used a localDB in development phase, now I want to go to production phase and want to export the sql server localDb to the online SQL server database, but I cannot find any option to script out the localDb or migrate it?
Which tools I can use to do this ? or what I must do?
There are atleast two routes; you could publish and recover as Data Tier Application:
Or, the easier-but-lengthier route would be to:
Create a new DB in the SQL Server Management Studio (Naming it the same as LocalDB is helpful if you just want to change the connection string later)
Right-click database on SQL Server Object Explorer and select Schema Compare
Click Select Target and navigate through Select Target Schema(Dialog) > Database > Click on Select Connection > Connect(Dialog) > Browse > Local > Database Name > Select the Databse you created in Step-1. Then, click OK
Click Compare or, hit Shift+Alt+C
Then, the Schema Comparator tells you whats different between the two databases (the one from MSSqlLocalDB and the one you just created in Step-1). It is important to remember unchecking ANY entries for delete operations, if you are simply transferring data and schema. Keep add operations as it is.
Then, click on ↑UPDATE (the option is located right beside Compare)
Your Target database should be updated
You can attach the localDb to SQLServer 2005 or higher and then you can generate scripts or export data to remote server.
Or
If LocalDb is SQL Server 2012, use SSMS 2012 or later for this scripting task.
Unfortunately VS2013 does not has any feature to script out a localDb, I waste so many time to copy table by table scripts, and run it at remote db. my local db id sql v11.0 (2012 I think). and the remote db was sql server 2008. so one way exist is to install an instance of sql server 2012 and sql server management studio to script out my db. maybe another tools also exist it is very sad that vs has not this feature.

How to restore SQL Server 2014 backup in SQL Server 2008

Were there any changes in this area with SQL Server 2014? I’ve seen this post Is it possible to restore Sql Server 2008 backup in sql server 2005 and I know that this was not possible as a scenario for 2012 -> 2008 but I wonder if MS made any changes here with the 2014 version.
We are evaluating 2014 version and we have a fairly large database in testing. We’d like to restore a backup of that database to SQL Server 2008 because that physical machine has more space, RAM,…
I’m getting standard error message when I try to restore backup but I was wondering if there is something else in SQL Server 2014 that I might be missing.
No, it is not possible. Stack Overflow wants me to answer with a longer answer, so I will say no again.
Documentation: https://learn.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql#compatibility
Backups that are created by more recent version of SQL Server cannot
be restored in earlier versions of SQL Server.
Not really as far as I know but here are couple things you can try.
Third party tools: Create empty database on 2008 instance and use third party tools such as ApexSQL Diff and Data Diff to synchronize schema and tables.
Just use these (or any other on the market such as Red Gate, Idera, Dev Art, there are many similar) in trial mode to get the job done.
Generate scripts: Go to Tasks -> Generate Scripts, select option to script the data too and execute it on 2008 instance. Works just fine but note that script order is something you must be careful about. By default scripts are not ordered to take dependencies into account.
It is a pretty old post, but I just had to do it today. I just right-clicked database from SQL2014 and selected Export Data option and that helped me to move data to SQL2012.
Pretty old question... but I had the same problem today and solved with script, a little bit slow and complex but worked. I did this:
Let's start from the source DB (SQL 2014) right click on the database you would like to backup -> Generate Scripts -> "Script entire database and all database objet" (or u can select only some table if u want) -> the most important step is in the "Set Scripting Options" tab, here you have to click on "Advanced" and look for the option "Script for Server version" and in my case I could select everything from SQL 2005, also pay attention to the option "Types of data to script" I advice "Schema and data" and also Script Triggers and Script Full-text Indexes (if you need, it's false by default) and finally click ok and next. Should look like this:
Now transfer your generated script into your SQL 2008, open it and last Important Step:
You must change mdf and ldf location!!
That's all folks, happy F5!! :D
No I guess you cannot restore the databases from higher version to lower version , you can make data flow b/w them i,e you can scriptout.
http://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/
Please use SQL Server Data Tools from SQL Server Integration Services (Transfer Database Task) as here: https://stackoverflow.com/a/27777823/2127493
If you have both versions you can create a merge replication from new to old. Create a merge publication on your newer sql server and a subscription on the older version. After initializing the subscription you can create a backup of the database with the same structure and the same content but in an older version and restore it on your old target server.
You can use this method also with sql server 2016 to target 2014, 2012 or 2008.

How to RESTORE a BACKUP from DB with different versions? [duplicate]

How to restore a higher version SQL Server database backup file onto a lower version SQL Server?
Using SQL Server 2008 R2 (10.50.1600), I made a backup file and now I want to restore it on my live server's SQL Server 2008 (10.00.1600).
When I tried to restore the backup onto SQL Server 2008 it gives an error i.e. Restore Failed because:
The database was backed up on a server running version 10.50.1600.
That version is incompatible with this server, which is running version
10.00.1600.
How do I restore the backup file on this server?
You can use functionality called Export Data-Tier Application which generates .bacpac file consisting database schema and data.
On destination server, you can use Import Data-Tier Application option which creates and populates new database from pre-created .bacpac file
If you want just to transfer database schema, you can use Extract Data-Tier Application for creating file and Deploy Data-Tier Application for deploying created database schema.
I've tried this process on different versions of SQL Server from SQL 2014 to SQL 2012 and from SQL 2014 to SQL 2008R2 and worked well.
No, is not possible to downgrade a database. 10.50.1600 is the SQL Server 2008 R2 version. There is absolutely no way you can restore or attach this database to the SQL Server 2008 instance you are trying to restore on (10.00.1600 is SQL Server 2008). Your only options are:
upgrade this instance to SQL Server 2008 R2 or
restore the backup you have on a SQL Server 2008 R2 instance, export all the data and import it on a SQL Server 2008 database.
You can not restore database (or attach) created in the upper version into lower version. The only way is to create a script for all objects and use the script to generate database.
select "Schema and Data" - if you want to Take both the
things in to the Backup script file select Schema Only -
if only schema is needed.
Yes, now you have done with the Create Script with Schema and Data of the Database.
Will not necessarily work
Backup / Restore - will not work when the target is an earlier MS SQL version.
Copy Database - will not work when the target is SQL Server Express: "The destination server cannot be a SQL Server 2005 or later Express instance."
Data import - Will not copy the schema.
Will work
Script generation - Tasks -> Generate Scripts. Make sure you set the desired target SQL Server version on the Set Scripting Options -> Advanced page. You can also choose there whether to copy schema, data, or both. Note that in the generated script, you may need to change the DATA folder for the mdf/ldf files if moving from non-express to express or vice versa.
Microsoft SQL Server Database Publishing Services - comes with SQL Server 2005 and above, I think. Download the latest version from here. Prerequisites: sqlncli.msi/sqlncli_x64.msi/sqlncli_ia64.msi, SQLServer2005_XMO.msi/SQLServer2005_XMO_x64.msi/SQLServer2005_XMO_ia64.msi (download here).
Here are my 2 cents on different options for completing this:
Third party tools: Probably the easiest way to get the job done is to create an empty database on lower version and then use third party tools to read the backup and synchronize new newly created database with the backup.
Red gate is one of the most popular but there are many others like ApexSQL Diff , ApexSQL Data Diff, Adept SQL, Idera …. All of these are premium tools but you can get the job done in trial mode ;)
Generating scripts: as others already mentioned you can always script structure and data using SSMS but you need to take into consideration the order of execution. By default object scripts are not ordered correctly and you’ll have to take care of the dependencies. This may be an issue if database is big and has a lot of objects.
Import and export wizard: This is not an ideal solution as it will not restore all objects but only data tables but you can consider it for quick and dirty fixes when it’s needed.
Another way to do this is to use "Copy Database" feature:
Find by right clicking the source database > "Tasks" > "Copy Database".
You can copy the database to a lower version of SQL Server Instance. This worked for me from a SQL Server 2008 R2 (SP1) - 10.50.2789.0 to Microsoft SQL Server 2008 (SP2) - 10.0.3798.0
You can try this.
Create a Database onto SQL Server 2008.
Using Import Data feature import data from SQL Server R2 (or any higher version).
use "RedGate SQLCompare" to synchronize script.
Go to Task->Generate Scripts...
In Advanced in "Types of data for script" select "Schema and data" and try to run this script in your lower version.
It's not pretty, but this is how I did it granted you have this option installed on your SQL 2008 R2 install..
1) Right click database in SQL Server 2008 R2 "Tasks".. "Generate scripts" in the wizard, select the entire database and objects in first step. On the "Set Scripting Options" step you should see a button "Advanced" , select this and make sure you select "Script for Server Version" = SQL Server 2008" not R2 version.
This is a crucial step, because "import data" by itself does not bring along all the primary keys, constriants and any other objects like stored procedures."
2) Run the SQL script generated on the new install or database instance SQL Express or SQL Server 2008 using the query window or open saved .sql script and execute and you should see the new database.
3) Now right click on the new database and select "Tasks".. "Import Data.." choose source as the R2 database and the destination as the new database. "Copy data from one or more tables or views", select the top checkbox to select all tables and then next step, run the package and you should have everything on a older version. This should work for going back to a 2005 version as well. Hope this helps someone out.
you can use BCP in and out for small tables.
BCP OUT command:-
BCP "SELECT * FROM [Dinesh].[dbo].[Invoices]" QUERYOUT C:\av\Invoices1.txt -S MC0XENTC -T -c -r c:\error.csv
BCP IN command:-
Create table structure for Invoicescopy1.
BCP [Dinesh].[dbo].[Invoicescopy1] IN C:\av\Invoices.txt -S MC0XENTC -T -c
I appreciate this is an old post, but it may be useful for people to know that the Azure Migration Wizard (available on Codeplex - can't link to is as Codeplex is at the moment I'm typing this) will do this easily.
You'd have to use the Import/Export wizards in SSMS to migrate everything
There is no "downgrade" possible using backup/restore or detach/attach. Therefore what you have to do is:
Backup the database from the server running the new SSMS/SQL version.
Import data from the generated .bak file, by expanding the "Tasks" menu(after right-clicking the target database) and selecting the "Import Data" option.
You can generate script from Task menu
For detailed reference
How to migrate a SQL Server database to a lower version

Is it possible to restore data from a table in sql server 2005 to sql server 2008?

A client has no option but to migrate from sql server 2000 to 2008 within the next few days. Tests have shown unacceptable performance degradation in vital functionality in 2005 but not in 2008. Good stuff however, the application uses DTS to import external market data into the database and DTS is no longer supported by 2008.
Until such time as the function can be rewritten, I'm thinking the import could be done in an instance of 2005 and the data (from one table) subsequently uploaded into 2008.
(a) is there an alternative option?
(b) if not, is there a simple way of achieving the data upload from 2005 to 2008?
Any assistance/advice gratefully received.
I might be misunderstanding what you need to do, but one thing you can do to move a database from from 2005 to 2008 is to just back up the database on the 2005 instance to a .bak file: right-click on the database in the Object Explorer in Management Studio (or whatever it's called in your version of SQL Server!), and do Tasks -> Backup database, and save it somewhere you can see from both instances. Then go to the 2008 instance do "Tasks -> Restore database" in the 2008 instance and the restored copy of the database should just work in 2008.
I think you might have trouble going the other way though, with this method.
You could use an SSIS package to execute the DTS packge, and AFAIK you can execute DTS 32 bit in SQL 2008 (MS link). The other option would be to run the database in a compatibility mode which ~may~ avoid the performance issues you're seeing. All in all, you might be better off rewriting your DTS with SSIS. The concepts similar and you shouldn't have too much trouble recreating it with SSIS.

DB cannot be opened because it is version 655. This server supports version 612

I'm trying to do some excercises from exam 70-515. Unfortunately I fail while trying to attach Northwind to a grid-control. It would result in:
NORTHWND.MDF' cannot be opened because it is version 655. This server supports version 612 and earlier. A downgrade path is not supported.
I use Windows 7 Home and MS Visual Web Developer 2010 Express. As fas as I understand this error, SQL Express must be an old version on my system. I downloaded and installed SQL Express 2008r2 from here. No effect. From other sources I figured out that I might need to change the instance name: Tools -> Options -> Database Tools -> Data Connections -> SQL Server Instance Name. There it is written SQLEXPRESS. I don't know what else I should insert there?
Turns out that deinstalling SQL Express and reinstall the latest version fixed the problem. I chose SQLSERVER2008 as Instance-Name while installing and set it in Visual Studio as described above.
Go to the Services control panel and look for a service named SQL Server (XXX) -- that XXX is the name of the instance that service is running. You just have to find the 2008R2 instance that you installed and type that into the "SQL Server Instance Name" box.
Might help to try to change the compatibility level, to make sure its backwards compatible.
Verify what level it is
USE VJ_DATABASE;
GO
SELECT compatibility_level
FROM sys.databases WHERE name = 'VJ_DATABASE';
GO
Then make it compatible with the older version
ALTER DATABASE VJ_DATABASE
SET COMPATIBILITY_LEVEL = 110;
GO
100 = Sql Server 2008
110 = Sql Server 2012
120 = Sql Server 2014
By default, Sql Server 2014 will change the db versions compatibility to only 2014, using the ## version you should be able to tell, which version Sql Server is.
Then run the command above to change it the version you have.
Additional step: Ensure you look at the accessibility of the DB is not reset, do this by right clicking on properties of the folder and the database. (make sure you have rights so you don't get an access denied)
I read this post but nothing helped me. Then I tried a few other options.
The way that I found that worked was to export the database and stored procedures from the original database. Then upload them into the second database(second computer).
Firstly export the DB content (data) - I used SQL server export data wizard. on the database you wish to export from right click then choose tasks, then export data. Follow the instructions and save in whichever format is best for you - I used excel for the data.
then to export the stored procedures rightclick the database name again. choose tasks and this time choose generate scripts. again follow the instructions of the wizard.
To import the data simply go to the second computer and right click the database you wish to import the data into. again tasks > import data. Follow the instructions to import all of the data from the database.
Finally to import the stored procedures, I opened up a new stored procedures command and dragged and dropped the script file that I had previously saved them in and dropped it into this window. The new stored procedure window filled with the entire list of my stored procedures. Finally change the name of the database name that will be used by the SP ( if this is different from the original DB name). (This is the first line USE [DBName]. then simply execute and the SP's will be fully restored.
This has helped me get my entire database up and running again very quickly. Hope this helps.
The SQL Management Studio is different than the SQL Server Version (or Database version). Example: At the current time, my work computer has SQL Server 2012 Management Studio but the SQL Version is 9.0 – which is SQL Server 2005. The SQL Management studio is only an IDE (Integrated Development Environment) and is NOT the same as the SQL Server version.
If when you try to Attach a Database, if you get an error similar to the following:
“The database 'AdventureWorks2008' 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 'AdventureWorks2008'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)”.
It means that the Database that you are trying to Attach was created with a Newer SQL version then what your computer has and you will NOT be able to use it. See if they have that Database that was created with the same or earlier version of SQL Server that your computer uses. In this case, I found the same Database that was created with SQL Server 2005 (Version 9).
A quick way to check what SQL Server version the computer is running, from the Windows desktop, go to Task Manager (Ctrl+Shift+Esc), click on the Processess tab, find and select the entry named “sqlservr.exe”, right click and choose Properties, click on the Details tab look at Product Version (Ex. 9….) or File Version (File version states the year and the version - Ex. 2005.9…).
Really this is the same error that i get, but until now i did not solve the problem!!
Go to Tools>Options>Data Connections, provided you have installed SQL Server Express 2008r2, leave the SQL Server instance name blank.
This happens when you are trying to use the SQLServer Express to connect to the MDF file. To remedy this issue, you need to go to Services.msc and turn on SQL Server services. You need to set the log on properties and when the service is started, you will be able to connect to the MDF file without any issues.

Resources