Solved

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

Posted on 2016-09-14
3
41 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 45

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 45

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now