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

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
LVL 17
MIKESoftware Solutions ConsultantAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you will find this query useful:

INSERT INTO TableB ( col1, col2, col3 .... )
  SELECT col1, col2, col3 ...
   FOM tableA
   WHERE ...
0
 
Ashish PatelCommented:
Insert Into TableA (Col1, Col2, Col3....)
Select Col1, Col2, Col3...
From TableB
0
 
MIKESoftware Solutions ConsultantAuthor Commented:
thanks....so there isn't a way to use a WILDCARD Character...like

INSERT INTO TableB ( col1, col2, col3 .... )
  SELECT *   <---------- ???
   FOM tableA
   WHERE ...
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
MIKESoftware Solutions ConsultantAuthor Commented:
Ok..I would be running this SQL script manually...and the data tables are IDENTICAL in column names etc...

Thanks for the information....
0
All Courses

From novice to tech pro — start learning today.