Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate Scripts of Certain Columns from a table in SQL Server 2008 management studio

I have a SQL Server 2008 database. This database has a table with 6 columns in it. I want to generate the insert scripts associated with the data only. I know how to do this part with SQL Server management studio via the "Advanced" dialog in the "Generate Scripts..." wizard. My challenge is, I only want to script 5 of the 6 columns. How do I do this?

like image 869
Phone Developer Avatar asked Oct 16 '25 01:10

Phone Developer


2 Answers

Check out the FREE SSMS Tools Pack v2.0 - it has among a lot of other things a feature to generate INSERT statements for data in your tables, and yes - you can pick for which columns that INSERT statement should be:

enter image description here

like image 196
marc_s Avatar answered Oct 18 '25 19:10

marc_s


SELECT Column1,Column2,Column3,Column4,Column5 INTO new table FROM your Existing table;

This will create a new table with the columns that you specified, then the data will be inserted in the new created table. Then script the new table that have only the five columns that you want.

like image 42
Joshki Avatar answered Oct 18 '25 20:10

Joshki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!