Importing Sql Server 2005 database into Sql Server express 2008 - sql

Is there any way to import a database backup from 2005 into 2008 express edition. What I've had to resort to is doing a script the database, then import all the data through DTS. Whenever I tried to import straight from a backup file it says something about not being to import into a new version of sql server or I'll get the below error.
title: Microsoft SQL Server Management Studio
Specified cast is not valid. (SqlManagerUI)

SQL 2005 backups should be restored on 2008 without problem (have done that myself many times). What exact error message did you got about versions?
The other error (Specified cast is not valid) seems to be Management Studio error, not server error. Have you full rights on 2008 server?
Look at this question - any-reason-to-have-sql-server-2005-and-2008-installed-on-same-machine - there are talked both about restoring SQL2005 backups and about attaching SQL2005 data files.
(Of course you cannot attach production databases. To attach non-production databases just detach them, make file level copy of these and attach copies to new server. Orginal files need to attach to original server too :))

I imagine that you are in a development process where your data will have to be regularly copied to you SQL 2008 server.
You can then think of configuring a replication between the SQL 2005 server (publisher) and SQL Server Express 2008 (suscriber). Depending on your requirements, you have the choice between snapshot or merge replication. If no update is done on the suscriber side, go for snapshot.
Once you want to have your 2008 server running independantely from the publisher, just delete the replication.

A valid SQL Server 2005 Express backup file should be able to be restored to SQL Server 2008 Express. If the SQL Server 2005 backup is from the Standard or Enterprise versions, you might hit problems restoring it to Express. The user context that the backup was created from should not affect the ability to restore that backup.
One thing you can do is to try running the restore operation as a verification, without actually trying to run the restore. That will tell you if the backup file is valid or not. You can use this syntax:
RESTORE VERIFYONLY
FROM yourbackupfile.bak

If possible, I would also suggest trying to simply detach the original database from 2005 and then attaching the file at the 2008 edition.
While I have only tried this with the standard edition myself, it has worked perfectly with the compatibility mode keeping the database set to 2005.
Have you tried running the Upgrade Advisor http://www.microsoft.com/download/en/details.aspx?id=11455 - it might be able to highlight problems for upgrading the original database.

Related

How to import Sql Server 2008 database into sql server 2012

My problem is I am working on a project and its database is created in SQL Server 2008. But I has SQL SERVER 2012 installed in my PC. I cannot import this file into my sql server and also cannot connect this database file with visual studio 2013
Help me please
The easiest way is creating a database backup in 2008, and restoring that into 2012. Should work without any issues, and the restore process will automatically upgrade the database to 2012.
Alternatively, it should also be possible to detach the database from 2008, after which you can copy the files (Do not move them, but copy. That way if anything goes wrong, you have a fallback option). You should then be able to attach it in 2012, which again, will convert the database to 2012.
There's also an option of using the copy database wizard from inside SSMS, which also converts the database.
Please note that if you convert the database, from that moment onwards, all other developers will have to upgrade to 2012 as well.

Conversion from LocalDB (.mdf) file to SQL Server Express .mdf file and reverse process

Since we need to move around our database a lot (like update it with new Rows which are generated by code and then update it prod db and reverse process). SQL Server CE, being a file based system was very helpful.
We would like to upgrade to use SQL Server Local Db but at the same time, it has limitations of use with IIS (though possible with AttacheDbFile). In this regard, since LocalDb is more or less a version of SQL Server Express, would it be possible to use our SQL Server LocalDB .mdf in our development environment and then copy them in prod but use by attaching to a SQL Server Express instance?
If yes, what additional thing, we need to do make it possible?
Also, we would like the reverse process to be worked out as well, mean detach the .mdf file and use it as LocalDb in development environment. I have read the great blog articles of
Krzysztof Kozielczyk also but not have experimented much with LocalDb.
LocalDB IS SQL Server Express (introduced with SQL Server 2012 Express), and the .mdf file is identical between LocalDB and SQL Server Express (and even a "full" SQL Server edition like Web, Standard or Enterprise Edition).
The only caveat is: you need to be using the same versions of those databases, since the file format is only identical amongst same versions, and can only be used amongst the same versions (e.g. 2012) - or it can be "upgraded" to the next newer version (e.g. you could move a database from LocalDB 2012 to a SQL Server 2014 Express once it's released) - but you can never go back down to an earlier version (you cannot take a LocalDB 2012 .mdf database file and attach it to a SQL Server 2008 version).

Restoring a MSDE database to SQL Server 2005

I am having a hard time trying to get a SQL Server 7.00.1094 backup to restore to a 9.00.1399 (MSDE to 2005) I was told that this will work. However I have done some research and all signs point to detaching and then attaching to the 2005 instance. The software provider specifically said I have to do a backup and restore, not a detach and attach. What is a good way around this? I am unable to upgrade the current instance to 2005 from 7.0.
I am able to add a new database to the 2005 instance, and restore other databases from the 7.0 instance by overwriting the new database I create, I only get this error when trying to restore the master database.
I guess the main question is, how do I successfully restore the system databases from 7.0 (7.00.1094) to 2005 (9.00.1399).
System.Data.SqlClient.SqlError: The backup of the system database on the device C:\test db run\mvdbtest cannot be restored because it was created by a different version of the server (7.00.1094) than this server (9.00.1399). (Microsoft.SqlServer.Express.Smo)
One workaround would be to download the 2000 version of MSDE, restore your database to that instance, then take a backup from 2000, and restore that backup to 2005. This is the same approach you have to take today in order to get a database from 2000 to 2012.

How to automatically restore a SQL Server 2008 R2 backup file

My team needs to update an automated content process running over SQL Server 2008 servers to include the content of a SQL Server 2008 R2 database delivered by a third-party vendor.
The request to third-party to deliver us on SQL Server 2008 is NOT an option.
My common sense indicates there is no way to downgrade from 2k8 R2 to 2k8 as in most of the software products I know. However, I'm wondering if I would be able to do something like this in a script:
Restore SQL Server 2008 R2 .bak file onto our SQL Server 2008 R2 instance
Update compatiblity level to SQL Server 2008 (100). Here is the bug in my plan: I've not found any compatiblity level distinctions between 2008 versions in internet. Any clue on this?
Backup the database.
Restore the database in SQL Server 2008
There may be some other ideas you may want to share with me.
Just recall there should not be manual intervention on this database conversion since this operation needs to be incorporated to an automated process.
Any help/suggestions/comments will be welcome!
No, you cannot restore a database backwards, regardless of compatibility level. Compatibility level affects certain database engine behaviors, but does not downgrade the database version. You will never be able to restore onto 2008 a database that ever existed in a 2008 R2 instance.
For workarounds, you can:
restore the database on R2, then use the import/export data wizard (or a third party tool) to transfer schema / data to the 2008 instance (and you should be able to automate this to some extent, e.g. Red-Gate's tools have command-line interfaces)
upgrade your 2008 servers to 2008 R2 or 2012
push back on the vendor
By design, you can only restore a DB backup to the same or newer version of SQL Server. A backup created with SQL Server 2008 R2 can only be restored with SQL Server 2008 R2 or SQL Server 2012. This is regardless of the compatibility level of the database. It's a limitation of the backup and restore procedures. This has been a limitation since prior to SQL Server 2000 (i.e., every version I've ever used).
Maybe you can script out the creation of new database, instead of backing up and restoring you basically just do a data dump with script.
Try looking at this How can I get a SQL dump of a SQL Server 2008 database?

SQL Server 2008 Version Problem [duplicate]

I am getting following error.
Restore failed for Server
I have recently upgraded SQL Server 2005 Express to SQL Server 2008 Express.
I have taken a Backup on Production Server, having SQL Server 2008
Backup was good and I tried restoring Backup on Production Server, that works great.
Than I downloaded that backup file in .Zip format with FileZila Software (And that is good too).
But when I tried to restore that file I am getting following error.
Restore failed for Server
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------ ADDITIONAL INFORMATION:
The media family on device 'C:\go4sharepoint_1384_8481.bak' is incorrectly formed. SQL Server cannot process this media family. RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4053&EvtSrc=MSSQLServer&EvtID=3241&LinkId=20476
Things I tried which didn't worked
Attempt 1
Try to take backup using following command
BACKUP DATABASE go4sharepoint_1384_8481
TO DISK='C:\HostingSpaces\dbname_jun14_2010_new.bak' with FORMAT
And tried restore that file.
Attempt 2
Somebody wrote to test Version of my SQL Server.
When I tried to run following command in SQL Server 2008
Select ##Version
It is giving following output
Microsoft SQL Server 2005 - 9.00.4053.00 (Intel X86) May 26 2009 14:24:20 Copyright (c) 1988-2005 Microsoft Corporation Express Edition on Windows NT 6.0 (Build 6002: Service Pack 2)
My Production Database is in SQL Server 2008, and I am trying to restore DB in SQL Server 2008 but above version is showing as if i am using SQL Server 2005.
Any idea how can I restore SQL Server 2008 DB.
Many Thanks.
Is it possible that, instead of upgrading your 2005 instance to 2008, you instead installed 2008 side-by-side with 2005, and you're connecting to your existing 2005 instance? Look for other instances on your machine.
You cannot restore a backup from a higher SQL Server version on a lower version - this has never been able in SQL Server.
If you have a SQL Server 2008 backup, you can only restore that on a SQL Server 2008 (or later) machine - but not on a 2005 box. No trick, no workaround, no way to do it.
You have 2 options here.
Use WITH REPLACE while using the RESTORE command. This will overwrite the existing database and restore the database state represented by the backup files.
Delete the database to which you are trying to restore to and restore again using RESTORE command. This will create a new database with the state represented by the backup files.
Please note that in both these options you will lose the existing data of the database you are trying to restore to.
Make sure it is installed correctly - in your program files\microsoft sql server directory there whould be a 100/150 folder. Check out the install log in setup bootstrap\log.
As described above the reason for this behaviour is that by default SQL Server doesn't allow restoring a database backup to an older version of SQL Server, regardless of the compatibility level of the database the backup was taken from.
You can try to:
Start SQL Server Management Studio and connect to the instance where the database resides
In the database context menu navigate to Tasks | Generate Scripts…. This will invoke the Generate and Publish Scripts wizard
In the Introduction step of the wizard click Next
In the Choose Objects step of the wizard make sure that the Script entire database and all database objects option is selected and click Next
In the Set Scripting options step of the wizard:
Select the Save scripts to a specific location option
Specify whether the database objects and data will be scripted to a single file multiple files, as well as the path and encoding of the generated scripts
Click Advanced
In the Advanced Scripting Options dialog that will appear:
Specify the version of the SQL Server you need the database restored to in the Script for Server Version option
In the Script for Server Version option specify Schema and data
Set the following options to True:
Script Logins
Script Full-Text Indexes
Script Triggers
Click OK
Click Next
In the Summary step of the wizard click Next
In the Save or Publish Scripts step of the wizard click Finish
Execute the generated SQL script(s) against the older SQL instance
Although the procedure listed above should work:
1. It doesn’t migrate all of the database objects (e.g. sequences or queues)
2. It might fail if your database contains dependencies which SQL Server fails to recognize (e.g. dependencies to databases residing on linked servers)
You can take a look at the rest of the article on Solution center. There is also third party tools you can take in consideration.