Automatically create an insert statement based on values in a table.

I have a test table with values inserted into it.  I want to create and insert statement to insert all the values into a production statement based on what is in test. Is there any easy way to create the statement?
Who is Participating?
Vitor MontalvãoConnect With a Mentor MSSQL Senior EngineerCommented:
In the Production SQL Server instance create a Linked Server for the Test MSSQL instance and run the following in the Production database:
INSERT INTO TableName (Col1Name, Col2Name, ..., ColnName)
SELECT (Col1Name, Col2Name, ..., ColnName)
FROM TestLinkedServer.TestDB.dbo.Tablename

Open in new window

Vitor MontalvãoMSSQL Senior EngineerCommented:
vbnetcoder, any feedback will be appreciated.
vbnetcoderAuthor Commented:
That helps -- thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.