.NET Daily

SQL

How to Generate SQL Insert Statements for a Populated Table – SQL Server 2008 R2

Posted on .

How to Generate SQL Insert Statements for a Populated Table – SQL Server 2008 R2

Introduction

Let’s say you want to export some data from your database SQL table to another database. If you have a decent number of items, for example less than 5000 entries, you can use the Script Wizard tool for that.
Follow the steps below to learn how to use Script Wizard:

Step 1) Right click on the database and select Generate Scripts…

Step 2) If you see the Introduction panel, click next, if not, go to next step.

Step 3) From the Choose Objects panel, click on Select specific database objects then select the database from which you want to export the data.

Generate SQL Insert Statements - step 3

Generate SQL Insert Statements – step 3

Step 4) From the Set Scripting Options panel, click Save scripts to a specific location then click Advanced and from General section, at Types of data to script select Data only and click Ok. After that you have to specify the path of the file where you want the script to be saved and click Next.

Generate SQL Insert Statements - step 4

Generate SQL Insert Statements – step 4

Step 5) After the Summary panel has appeared, click Next again and when the export is completed, click Finish.

That’s it! Now go and open the generated file and make use of the generated data.

Note: If you want to include in the generated file the SQL script for the creation of the table/s, please modify the Types of data to script to Schema and data at step 4).

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.

Comments
  • user

    AUTHOR Zaheerulla

    Posted on 9:58 am March 19, 2012.
    Reply

    Try the stored procedure given at http://blogunlimited.com/MohammedRashid/archive/2012/03/10/generate-insert-statements-for-sql.aspx . It’s simple stored procedure with few parameters. It worked for me.

  • user

    AUTHOR darius

    Posted on 4:54 pm March 19, 2012.
    Reply

    Hi Zaheerulla,

    Thanks for the tip.

  • This site uses Akismet to reduce spam. Learn how your comment data is processed.

    View Comments (0) ...
    Navigation