Friday, November 11, 2016

Copy or Migrate Database from one MSSQL to Another

Description:  There are two methods to copy or migrate database from one machine to another

Method-1: Backup database and Restore it to another:

      ·         Open SQL Management Studio
      ·         Choose your database
      ·         Right Click, go to Tasks ---> Backup
      ·         In the database backup windows, click add and then give backup path and file name and click ok
      ·         Copy backup file to destination machine
      ·         Open SQL Management studio on destination machine
      ·         Create new database
      ·         Right click on newly created database, go to Tasks ---> Restore--> Database
      ·         on the restore window select from device option
      ·         Add backup file path
      ·         Click Ok


Method-2: Copy .mdf and .ldf file from source machine to destination machine. You need to take database offline to copy .mdf and .ldf file of database

      ·         You need to take database offline. For offline choose database
      ·         Right Click, go to Tasks ---> Take Offline
      ·         Copy database and log file from database directory and paste it to destination machine in  database directory
      ·         On Destination machine, Open SQL Management studio
      ·         Right Click on Databases, go to Attach
      ·         Click on Add button and select database file that you have copied
      ·         Don’t forget to online database in source machine

No comments:

Post a Comment