Reputation: 9279
I have a SQL Server 2008 db. It contains some great test data...a proposal that has a lot of child records. I want to script this Proposal so as not to re-enter the data for each new environment. Is there a way to script the data in the proposal as well as all the dependent tables. I can run a query to get the data but what I really need is a set of SQL Insert Statements to insert the data into the new environments. At least that's what I think I need. Any ideas?
Upvotes: 1
Views: 481
Reputation: 7683
If you dont want to use 3rd party stuff, you can pretty much achieve this with SSMS out of the box, simply right click the database, hit "Generate Scripts", follow the wizard, on the options step, set "Script Data" to true (or, if your using 2012, set "Types of data to script" to "Schema and Data").
http://msdn.microsoft.com/en-us/library/ms178078.aspx
http://msdn.microsoft.com/en-us/library/ee210523.aspx
Upvotes: 2
Reputation: 280644
Several options for this exist.
If you're a DIY person and want a manual option with no support, check out Vyas' script:
http://vyaskn.tripod.com/code.htm#inserts
CodeProject article:
http://www.codeproject.com/Articles/5598/Generating-INSERT-statements-in-SQL-Server
Red Gate SQL Compare (to build the schema in the destination) and Data Compare (to pump data over there after the tables are created):
http://www.red-gate.com/products/sql-development/sql-compare/
SSMS Tools Pack:
http://ssmstoolspack.com/Features
Upvotes: 4