Hi,I have two tables (test, test_invoice) both filled in automatically; what i need to do is update whenever there has been a change in table test_invoice (literally new record with date of invoice).two tables:create table test(id_customer int not null,date1 smalldatetime,date2 smalldatetime,flag char(3))ALTER TABLE [dbo].[test] ADD CONSTRAINT [PK_test] PRIMARY KEY CLUSTERED ( [id_customer] ) ON [PRIMARY]GOinsert into test (id_customer, date1, date2, flag) values (2323, '2008-2-23', '', 'Yes')insert into test (id_customer, date1, date2, flag) values (2325, '2008-2-25', '', 'No')create table test_invoice(id_customer int not null,date_invoice smalldatetime)ALTER TABLE [dbo].[test_invoice] ADD CONSTRAINT [PK_test_invoice] PRIMARY KEY CLUSTERED ( [id_customer] ) ON [PRIMARY]GOinsert into test_invoice (id_customer, date_invoice) values (2325, '2008-3-2')insert into test_invoice (id_customer, date_invoice) values (2329, '2008-3-5')
so how do i make this update happening automatically whenever there is a new record in test_invoiceupdate tset t.date2 = ti.date_invoicefrom test as t inner join test_invoice as ti on ti.id_customer = t.id_customer
I'd say IF is missing in front of the update sentance...? :-)Thank you