By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

Suggestions Plz

P: 1
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..
Feb 14 '08 #1
Share this Question
Share on Google+
2 Replies


jamesd0142
100+
P: 469
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..
So B is a mirror of A ?

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)

Expand|Select|Wrap|Line Numbers
  1. delete A
  2.  
Feb 14 '08 #2

ck9663
Expert 2.5K+
P: 2,878
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..
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.

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.

-- CK
Feb 14 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.