Sunday, July 7, 2013

MSSQL database migration

To migrate an MSSQL database on another server, follow the steps given below.

1. Make a backup of the existing database.

  You can do that directly from the control panel or through MSSQL management studio.

 a. Login to MSSQL management studio and select the database
 b. Right click on the database > Task > backup > select the backup destination > click on "ok" button.


2. Copy the backup file to your local system through FTP

3. Upload the .bak file you got to the destination server.

4. Restore the database there.

     a. Create the database on the destination server through control panel or SQL management studio
     b. Login to MSSQL management studio and select the database
     c. Right click on the database > Tasks > Restore > Database
     d. under "Source for restore", select "From device" and browse the location of the file. It will then come under "Select the backup sets to restore"
    e. Select the appropriate backup and then go to the "options" on the top left side. check the button "overwrite existing database" there and click on "ok" button


This will do the restore and you can see a restore status option which shows the percentage of restore done. Once the restore is finished, you will get a message that the restore was successful.
   
PS: MSSQL is backward compatible. So, if the source server's MSSQL version is advanced than the destination server's version, you will probably end up in error.


You can restore the database using the .sql backup(Script). Follow the steps given below to generate a .sql backup
.

1. Generate a .sql backup.

 a. Login to MSSQL management studio and select the database
 b. Right click on the database > Task > Generate Script >  select "Script entire database and database objects' > click next
 c. Select an apropriate location where the backup should be saved and then click the "Advanced" button
 d. Under "General" > "Types of data to script" select "Data only" from the drop down menu > click "ok" > click "next".
 e. Click "next" for summary and the click "finish" to complete the backup procedure.


2. Download the .sql file to the local system

3. Upload it to the target system and then double click on it. That will make the .sql file to get opened in the query editor of MSSQL manager on the destination server. Just execute the query and that will do the task.

No comments:

Post a Comment