Tuesday, February 18, 2014

Generate insert scripts with data

There have been instances where we need to create insert statements for a table and share it across different dev /test environments.
We can do this pretty easily using SSMS. (Below screen shots are from SQL 2012)

First, right click on database from where you want to generate insert scripts with data -> Tasks -> Generate Scripts..

Next, Generate and Publish scripts wizard opens,
Click next on introduction page,

On Choose object page, select the required database object you want to script and then click Next.

On Set scripting options page, click on Advanced button as show below

On General listings, select drop down for "Types of data to script" and select "Schema and data" and then click OK.

then select the option whether to save it as file, or open in clipboard or to save it in new query window.
This way you can share insert scripts with data to your dev/test team.

Hope this helps !

No comments:

Post a Comment