I have two tables A & B.I Have 20 records that has to be inserted into table A and at the same Table B should also be updated.This procedure should happen on daily process and on each day the previous days data which is inserted should be deleted so that the present Data is added..
Suggestions Plz
Collapse
X
-
Tags: None
-
So B is a mirror of A ?Originally posted by joelprasad08I have two tables A & B.I Have 20 records that has to be inserted into table A and at the same Table B should also be updated.This procedure should happen on daily process and on each day the previous days data which is inserted should be deleted so that the present Data is added..
In that case...
create a query to find all the data in table A that is not in table B into a temp table.
them delete whats there in B already and add the data from the temp table to B
---------------
If you want to only store thae new data in a table consider running this command before you populate the table(s)
[code=sql]
delete A
[/code] -
if A = B, then why do you need 2 tables? If A is transactional and B is historical, add a field (ie TRAN_DATE) on B to identify when the reocord was inserted in B. Use table name convention in A (tram_yyyymmdd) . Create a scheduled batch to create this table on a daily basis.Originally posted by joelprasad08I have two tables A & B.I Have 20 records that has to be inserted into table A and at the same Table B should also be updated.This procedure should happen on daily process and on each day the previous days data which is inserted should be deleted so that the present Data is added..
I am not a fan of deleting tables and even records. Specially transactional. If you loose them, you loose them. Storage is much cheaper now that you can store those tables until you are 100% sure you don't need them. This cost always outweighs the gain.
-- CKComment
Comment