IT Made Simple

January 4, 2008

Migrating MSDE 2000 db to MSSQL 2005 Express

Filed under: Database, How to — EinsamSoldat @ 1:00 am

Scenario :
An ASP web application in which the backend DBMS is running on MSDE 2000 SQL Server.

Objective :
Making the ASP web application to use MSSQL 2005 Express on to the server. On top of that database created on the MSDE 2000 Instance needs to be migrated over to the MSSQL 2005 .

Scope :
1. MSDE 2000 SQL Server instance name is localhost\HELM , MSSQL db name HelmDb.
2. MSDE 2000 SQL Server instance is running at a non MSSQL default port (not 1433).
3. MSSQL Server 2005 Express is used.
4. Using default MSSQL Server 2005 Express instance localhost\SQLEXPRESS .
5. OS used Windows Server 2003.

Workflow :
1. Backup the raw database run the following command at the MSSQL Shell.
prompt > cd C:\Program Files\Microsoft SQL Server\80\Tools\Binn
prompt > osql -E -S .\\Helm
MSSQL prompt > sp_detach_db ‘HelmDb’
MSSQL prompt > go

2. Copy the mdf file e.g. HelmDb.mdf and place it at a safe location. The backup is complete.

3. Install the MSSQL 2005 Express .

4. Copy the HelmDb.mdf from the backup and place it into the physical location of MSSQL 2005 Express, usually it is located in path C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data .

5. Reattach the mdf file back to the db. But you need to remove the ldf file, e.g. HelmDb_log.ldf
prompt> cd C:\Program Files\Microsoft SQL Server\90\Tools\Binn
prompt> osql -E -S .\\SQLEXPRESS
MSSQL prompt > sp_attach_single_file_db @dbname=’HelmDb’, @physname=’C:\\Program Files\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\HelmDb.mdf’
MSSQL prompt > go

6. You should be able to see something like the screenshot below during the reattachment, take note that MSSQL 2005 Express will upgrade the mdf to a higher version automatically. Not to forget, a new ldf or transaction log file will be created automatically.

attach mssql2000 to mssql2005

7. Test the newly attached MSSQL 2005 Express db using SQL manangement express.

8. Change your web application connection string.

9. Well done, you have completed the migration.

3 Comments »

  1. good job well done.. u shld include this in office forum :-)

    Comment by Daaditsu — January 4, 2008 @ 4:39 pm

  2. Hi Duddits, I will paste this link to the office forum, increase my site traffic :D

    Comment by EinsamSoldat — January 4, 2008 @ 11:06 pm

  3. you can install the SQL Management Studio Express which allow you to do the attach/detach via GUI.

    Comment by andy — January 10, 2008 @ 2:21 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Powered by WordPress