Suggestions Plz

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • joelprasad08
    New Member
    • Feb 2008
    • 1

    Suggestions Plz

    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..
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    Originally posted by joelprasad08
    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)

    [code=sql]
    delete A
    [/code]

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Originally posted by joelprasad08
      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

      Comment

      Working...