Append data from table1 to table2 daily with no duplication

Moore71

DEVELOPER
Local time
Today, 15:15
Joined
Jul 14, 2012
Messages
158
Hi guys,i have 2tables,table1=productid,ProductName,Qty & table2=Productid,productName,Qty,currentDate.
I want to be able to append data programatically once daily OnClose.Although users can log-off & on as many times,but the Append should be once & after then,update subsequent records for that day automatically from table1-table2.
Thanks in advance
 
Moore71,

Insert:

Code:
Insert Into Table2 (Productid, ProductName, Qty, CurrentDate)
Select Table1.Productid, 
       Table1.ProductName,
       Table1.Qty,
       Date()
From   Table1 Left Join Table2 on
         Table1.ProductID = Table2.ProductID
Where  Table2.ProductID Is Null

Update:

Code:
Update Table2
Select Table2.ProductName = Table1.ProductName,
       Table2.Qty = Table1.Qty
From   Table1 Inner Join Table2 on
         Table1.ProductID = Table2.ProductID

But why not just make a backup of Table1.

They should be identical after the 2 SQL statements.

Wayne
 
Thank you Wayne for the response.I am quiet satisfied with your reply.
My next question is if i backup,can it be done daily?What if there's change in data after backup,because the essence of table2 is to keep daily history of stock inventory automatically without duplication
Thanks anyway
 

Users who are viewing this thread

Back
Top Bottom