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.
Advertisement
Answer
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.