Convert SQL Server Express 2005 .mdf to 2008 .mdf? - sql-server-express

Hi I have a Visual Studio solution and an ASP.NET MVC project that uses a SQL Server Express 2005 database file in the App_Data. I want to know how I can upgrade this file so it works for SQL Server Express 2008 ?
Thanks

You can issue the Attach command in SQL Management Studio 2008. It will name the database with the path to the .mdf, but it'll use it no problem.
The database will be in 2005 compatibility mode, but you can certainly change that yourself as you see fit.

All you have to do is create a backup (.bak) of your 2005 db and then restore it on your 2008 Express server. It's that simple.
If you want to deal with it on the file level, simply detach from 2005 and attach to 2008. If it's solution-created in your AppData all you should have to do is move it to the newer project.

alt text http://img714.imageshack.us/img714/4514/sqlserver.jpg
Looks like this database is actually 2008 from what that compatibility level says so I think I am ok. I figured out how to attach the file in SQL Server management studio but thanks for mentioning about the compatibility mode.
I tried out making a backup and then restoring it using the backup file as a database and it made a new mdf file in the same folder as the original which is what I wanted, wasnt very clear that it was going to do that. Thanks

Related

SQL Server 2012 Management Studio no attach option for mdf files

I am trying to attach a database to my Azure SQL using Management Studio 2012. However, there is no "Attach" option when I click on the Databases folder on the server. Could anyone make some suggestions how to attach a .mdf file ?
you cannot attach an .mdf directly to Azure SQL Database. neither can you restore a backup (.bak).
you can follow what sqluser pointed out above.
there's also other options like using Migration Wizard, bacpac, etc...
have a look here
Right click on your database ==> Tasks ==> Deploy database to SQL Azure

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.

How can I open sql server 2005 database after i do changes with visual studio 2010?

I´m trying to open sql server 2005 database with sql server management studio but i can´t. I have done changes in that database with visual studio 2010. Is there any solution to open that database?
The problem was that i connect to db in local mode, selecting mdf file manually and with windows identification. I connect with server mode, with db user and it works perfectly. thanks!!
If the database was set into single user mode like this
ALTER DATABASE YOUR_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
You can set it back to multi-user mode:
ALTER DATABASE YOUR_DB SET MULTI_USER
It looks a bit like you've got the Visual Studio holding it open in single use mode.
If you restart your machine, and (without opening visual studio) try to look inside the database using SQL Server Management Studio, that might fix your issue.
UPDATE: It looks like the database has been upgraded to SQL2008 as you surmised. You can download SQL2008 express and export data from your 2008 database to a new 2005 file (you'll need to do that from SQL2008 express)
Forum link describing same problem.

SQL Server 2005 mdf file on 2012

I have a SQL Server 2005 .mdf file I need to install on a server. Can I simply install SQL Server 2012 Express and attach the .mdf file without any issues, or should I stick to 2005 Express to eliminate any issues that may arise?
I should also add it needs to support a ASP.NET 3.5 website.
Cheers
If you have all files (mdf, ldf and potentially multiple ndf) and the database was cleanly shut down, you won't have an issue attaching to 2012.
If you have only the mdf it might work but it could also fail.
Either way, first take a backup of the files you have.
That being said, make sure you don't use any features that changed between 2005 and 2012 (see http://technet.microsoft.com/en-us/library/ms143532.aspx for details)

Importing Sql Server 2005 database into Sql Server express 2008

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.