Victor Rodrigues
Victor Rodrigues

Reputation: 11711

How to create automatically a table populate script from current data in SQL Server?

Is there a tool that allows me to create a sql populate script for a table using its current data?

Upvotes: 7

Views: 21432

Answers (6)

Slobodan Savkovic
Slobodan Savkovic

Reputation: 1057

Another way to do it, even more convenient for developers, is within Visual Studio 2015 or 2017 (possibly earlier versions too):

  1. Main menu 'View' -> 'SQL Server Object Explorer'
  2. In the tree view connect to the Database of choice and select a table
  3. Right click on the table and select 'View Data' menu item
  4. In the [Data] window click on a 'Script' or 'Script to File' button

Upvotes: 1

Gustav
Gustav

Reputation: 347

Old question, but I got to the question before figuring out a way to solve the problem. So I'm just posting the method here in case it might help anyone else.

In SSMS:

  1. Right click on db -> "Tasks" -> "Generate Scripts..."
  2. Click "Next" and, at "Choose Objects" step, select the specific table
  3. Click "Next" and, at "Set Scription Options" step, click "Advanced"
  4. Set value for "Type of data to script", depending on what you need
  5. Continue to finish

Upvotes: 10

marc_s
marc_s

Reputation: 754348

Check out the SSMS Addins (for both SSMS 2005 and 2008):

alt text http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=SSMSAddins&DownloadId=48526

One of the tools included in the "DataScripter" which will script out INSERT statements for the table(s) you want to.

Upvotes: 2

Giorgi
Giorgi

Reputation: 30873

You can do it with Database Publishing Wizard. Here is a tutorial: Generate Script with Data from Database – Database Publishing Wizard

Upvotes: 0

Scoregraphic
Scoregraphic

Reputation: 7200

Maybe this is just enough for you: http://snipplr.com/view/12003/generate-insert-statements/

Upvotes: 1

Kane
Kane

Reputation: 16802

You could look at purchasing the Data Generator by Red-Gate which can create random sets of data based on your database schema.

Note: I'm not sure if the tool will generate data based on your current data though

Upvotes: 0

Related Questions