Solved

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

Posted on 2016-09-14
3
59 Views
Last Modified: 2016-09-28
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
Comment
Question by:vbnetcoder
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41798098
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
 
LVL 48

Expert Comment

by:Vitor Montalvão
ID: 41820016
vbnetcoder, any feedback will be appreciated.
0
 

Author Closing Comment

by:vbnetcoder
ID: 41820058
That helps -- thank you.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question