Query that works like Select Into w/o overwriting the table

bonzovt
10-14-2004, 02:15 PM
I am trying to select data from a table and dump it into another. My problem is that every time I run the Select Into query, it overwrites all the old data in that other table. I want to be able to Select Into a table and ADD the info to the other table rather than having it overwrite the whole table each time.

For example, if my database is used everyday, I want some of that day's info dumped into another table that stores up to 3 days worth of old info. Is there a way to do this?

Granty
10-14-2004, 02:19 PM
You want to use INSERT INTO which appends data to a table.

bonzovt
10-14-2004, 02:30 PM
You want to use INSERT INTO which appends data to a table.

Here is my current statement:
SELECT * INTO tblHistory
FROM tblCustomerInfo
WHERE CarrierCode='FXG' or CarrierCode='FEC'

How would I transfer that to an INSERT INTO statement? I guess I just don't understand how to insert * where (field=something) from one table into another. Thanks for the help!

Granty
10-14-2004, 02:43 PM
INSERT INTO tblHistory
SELECT *
FROM tblCustomerInfo
WHERE CarrierCode='FXG' or CarrierCode='FEC'



Will work as long as they have the same fields, otherwise you have to list the destination and source columns in the orders you wish them to be translated.

bonzovt
10-14-2004, 03:22 PM
Thanks! That worked for me...I dunno why I couldn't find that combination as an example anywhere.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum