I need to create a INSERT script in order to insert in another database the same data.
If in SQL Server I select "Script table as > INSERT To" I can easily recreate the skeleton for the INSERT statement. However since I have several records to migrate, I would prefer to avoid having to insert the values manually.
Therefore is there any way to "automatically" get the INSERT script with also the values (coming from the target table) filled in?
I know this could be done with SSIS, but I am wondering whether it would be possible as well with a quicker solution.
Steps To Auto Generate INSERT StatementsFrom the right-click menu, go to Tasks >> Generate Scripts... In the Generate and Publish Scripts pop-up window, press Next to choose objects screen. Now, the choose objects screen, choose Select specific database objects and choose the tables you want to script.
You can do this with SSMS.
1 - Right-click your database in Object Explorer.
2 - Select Tasks/Generate Scripts...
3 - On the Set Scripting Options page, click the Advanced button and make sure Types of data to script is set to Data only.
The resulting script will have a USE DATABASE
statement at the top. Change this to the database you would like to insert the data into.
Use the free SSMS tools pack to "generate insert statements"?
Or in SSMS (don't have it on this PC to confirm) the export wizards allows you to "script data" too
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With