Solved

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

Posted on 2007-12-04
5
174 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
  • 2
  • 2
5 Comments
 
LVL 142

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 142

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Some sers suddenly getting error popup msg 28 89
insert wont work in SQL 14 21
VB.NET 2008 - SQL Timeout 9 24
Loops and updating in SQL Query 9 25
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

770 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