user1173169
user1173169

Reputation:

Generating a SQL script of my database's data (SQL SERVER)

I cannot find how to generate a script with all the INSERT i have done so far in my database I managed to generate a script for my database itself but not for the data.

How could i do this ? Thanks in advance

Upvotes: 12

Views: 19361

Answers (2)

Amal Dev
Amal Dev

Reputation: 1963

If you are using SQL Server 2008, you can generate the script for data in an sql server database by setting the Script Data option in Generate script dialog box

For bringing up Generate Scripts dialog do the following. 1. Right click on a database name in server explorer 2. Select Tasks -> Generate Scripts 3. Click next until you reaches script options 4. Under table/view options there is setting "Script Data". Change it to true to generate script for data.

If you version is the one prior to SQL Server 2008, then are many tools available like Sql Compare from RedGate!

Upvotes: 1

JohnD
JohnD

Reputation: 14787

Try this, using Sql Server Management Studio:

  1. Right click the database
  2. Select Tasks -> Generate Scripts
  3. (Click next if you get the intro screen)
  4. Select "Select specific database objects"
  5. Pick the objects to generate scripts for (tables, stored procedures, etc...)
  6. Click Next, then specify the output filename
  7. This will generate the schemas only. If you want to do data generating scripts as well, click the Advanced button and scroll down to the "Types of data to script" and change it from "Schema only" to "Data only" or "Schema and data"
  8. Click Finish to generate the script

Upvotes: 25

Related Questions