SQL Server database export table all data into INSERT statement

Source: Internet
Author: User

Sometimes we want to import all the data from one table of a database to another database or to a database on another computer, and for SQL Server there is a way

Here I take SQL Server R2, the database is the Northwind database, for example,

Objective: To export the Orders table of the Northwind database into an INSERT statement.

First step: Select the Northwind database, right-task-Generate script:

Second step: In the "Generate and publish script" in the introduction window, press the "Next" button:

Step three: In the Select Objects window, select Select Specific database objects, expand the table,

Tick the table where you want to generate the INSERT statement, and I've chosen the order form here.

Press the "Next" button:

Fourth step: In the "Set Scripting Options" window that pops up, press the "Advanced" button,

In the "Advanced scripting Options" pop-down drop-down bar to the bottom,

Set the data type to script to data only (data only is export data as INSERT statement, if you export the table structure, select Schema only, select schema and data, both schema and INSERT statements are generated), press the OK button:

Fifth step: In the "Set Scripting Options" window,

"Specify how to save or publish scripts" output type Select "Save script to a specific location",

Tick "Save to File", you can specify a saved path, save as. sql file,

Tick "Save to new Query window", a new query window opens and all INSERT statements are placed in the new query window:

Sixth step: In the "Set Scripting Options" window, press the "Next" button to eject:

Seventh step: In the "Summary" window, press the "Next" button:

Eighth step: In the "Save or Publish Script" window, press the "Finish" button:

A new query window is created automatically, and all the data in the order table is converted into an INSERT statement.

SQL Server database export table all data into INSERT statement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.