[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-12-04
5
Medium Priority
?
182 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

830 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