• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 73
  • Last Modified:

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?
0
vbnetcoder
Asked:
vbnetcoder
  • 2
1 Solution
 
Vitor MontalvãoMSSQL 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:
USE ProdDB
GO
INSERT INTO TableName (Col1Name, Col2Name, ..., ColnName)
SELECT (Col1Name, Col2Name, ..., ColnName)
FROM TestLinkedServer.TestDB.dbo.Tablename

Open in new window

0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
vbnetcoder, any feedback will be appreciated.
0
 
vbnetcoderAuthor Commented:
That helps -- thank you.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now