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

vbnetcoder
vbnetcoder used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Engineer
Distinguished Expert 2017
Commented:
In the Production SQL Server instance create a Linked Server for the Test MSSQL instance and run the following in the Production database:
USE ProdDB
GO
INSERT INTO TableName (Col1Name, Col2Name, ..., ColnName)
SELECT (Col1Name, Col2Name, ..., ColnName)
FROM TestLinkedServer.TestDB.dbo.Tablename

Open in new window

Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
vbnetcoder, any feedback will be appreciated.

Author

Commented:
That helps -- thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial