We are writing a new application, and while testing, we will need a bunch of dummy data. I've added that data by using MS Access to dump excel files into the relevant tables.
Every so often, we want to "refresh" the relevant tables, which means dropping them all, re-creating them, and running a saved MS Access append query.
The first part (dropping & re-creating) is an easy sql script, but the last part makes me cringe. I want a single setup script that has a bunch of INSERTs to regenerate the dummy data.
I have the data in the tables now. What is the best way to automatically generate a big list of INSERT statements from that dataset?
The only way I can think of doing it is to save the table to an excel sheet and then write an excel formula to create an INSERT for every row, which is surely not the best way.
I'm using the 2008 Management Studio to connect to a SQL Server 2005 database.
I have also researched lot on this, but I could not get the concrete solution for this. Currently the approach I follow is copy the contents in excel from SQL Server Managment studio and then import the data into Oracle-TOAD and then generate the insert statements
We use this stored procedure - it allows you to target specific tables, and use where clauses. You can find the text here.
For example, it lets you do this:
I use sqlite to do this. I find it very, very useful for creating scratch/test databases.
sqlite3 foo.sqlite .dump > foo_as_a_bunch_of_inserts.sql
The first link to sp_generate_inserts is pretty cool, here is a really simple version:
On my system, I get this result:
Jane Dallaway's stored procedure: http://docs.google.com/leaf?id=0B_AkC4ZdTI9tNWVmZWU3NzAtMWY1My00NjgwLWI3ZjQtMTY1NDMxYzBhYzgx&hl=en_GB. Documentation is a series of blog posts: https://www.google.com/search?q=spu_generateinsert&as_sitesearch=http%3A%2F%2Fjane.dallaway.com
GenerateData is an amazing tool for this. It's also very easy to make tweaks to it because the source code is available to you. A few nice features: