HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

Script to generate insert statements

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
scriptstatementsgenerateinsert

Problem

I am trying to write an SQL script to create an insert statement for each row of table TEST which has field A (int) and field B varchar(30), in my MS SQL database.

I would like to save those insert statements into a txt file to be able to apply that data back to another database.

Any idea about how to do it?

Solution


  • Right-click on your Database in Object Explorer



  • Select Tasks -> Generate Scripts...



  • In that wizard you will be able to select the desired object(s) that you'd like to script out



  • The next portion has an Advanced button, click that



  • Under General, you will see the option called Types of data to script. The options are Schema only, Schema and data, or Data only. I believe you want the last option (Data Only)

Context

StackExchange Database Administrators Q#20164, answer score: 8

Revisions (0)

No revisions yet.