Import database by generate script to MS SQL Server

In this post show how to import database to MS SQL Server by generate script. To import database from a server to other server, you must generate script of the database that you want to export first. After generate script is completed, it's time to create a query in the server that you want to import it into.

Introduction

      I want to export a database(Inventory) from a server (UBEE_THAROTH\SQLEXPRESS) to other server(UBEE_THAROTH).

I. Generate Script in a server(UBEE_THAROTH\SQLEXPRESS)
    1. Right click on the database that you want to export. When context dialogue appear, mouse over on Tasks and then choose Generate Scripts..... See picture below:
Generate database as scripts
Generate database as scripts
 2. When Select Database dialogue appear,  select the database in Select a database box and tick on Script all objects in the selected database(tick on this option  mean all objects in database will be export). Click Next.
Select database
Select database
 3.  Choose Script Options dialogue appear. In Script for Sever Version--> choose SQL Server 2005 if you want to export it to Microsoft SQL Server 2005. Click Next to continue.
Choose Script Option
Choose Script Option
 4. Output Option dialogue appear, choose Script to file and then click on Browse... to choose location for save script. After save script, click Next to continue.
Output Option to select the destination for the script wizard output 
 5.  Script Wizard Summary dialogue appear, click Finish.
Script Wizard Summary
Script Wizard Summary
 6.  Generate Script Progress dialogue appear. Wait until progress success all. click close.
Generate script progress
Generate script progress
 Now you have got a script database. It's time to import your database to the server that you want to import it into.
II. Execute script to import database 
       1. Before execute script, you need to create a new database or have existing database that you want to import into.

       2. Go to server that you want to import the database. Right click on server name. when the context dialogue appear, choose New Query.  
create a new query
Create a new query
3.  Open the script that you generated with Notepad. Press Ctrl + A to select all and copy it. And then paste it in  new query.Rename the database name the same as database that you want to import. Click on Execute to produce query for importing database. See picture below: 
Execute script to import database
Execute script to import database

Done ...Hope this post is helpful for you.

Import database by generate script to MS SQL Server Import database by generate script to MS SQL Server Reviewed by BeiLover on 11:57 PM Rating: 5

No comments:

Powered by Blogger.