Solved

INSERT contents of one table...into an existing table....?

Posted on 2007-12-04
5
175 Views
Last Modified: 2010-04-21
Experts:

Can I get the syntax for entering TableA into TableB. TableA contains the historical data and TableB has new data that needs to be populated INTO TableA.

Identical Columns....datatypes...etc..etc..

Thanks

MikeV
0
Comment
Question by:MIKE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20406904
you will find this query useful:

INSERT INTO TableB ( col1, col2, col3 .... )
  SELECT col1, col2, col3 ...
   FOM tableA
   WHERE ...
0
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20406934
Insert Into TableA (Col1, Col2, Col3....)
Select Col1, Col2, Col3...
From TableB
0
 
LVL 17

Author Closing Comment

by:MIKE
ID: 31412704
thanks....so there isn't a way to use a WILDCARD Character...like

INSERT INTO TableB ( col1, col2, col3 .... )
  SELECT *   <---------- ???
   FOM tableA
   WHERE ...
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20407041
if both tables are REALLY identical, then you could do this:

INSERT INTO TableB
  SELECT *
   FOM tableA
   WHERE ...

note that it is usually dangerous for be used in production...
0
 
LVL 17

Author Comment

by:MIKE
ID: 20407056
Ok..I would be running this SQL script manually...and the data tables are IDENTICAL in column names etc...

Thanks for the information....
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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…

730 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