SQL Server on update move to separate column -


my company requires column in customer table show number of previous addresses customer. number must update automatically whenever address updated.

 create trigger deleted_address on tblcustomer  instead of insert   begin  set nocount on   end 

so far have i've come issue don't know how make if address of customer edited adds old address new column called previousaddress , updates customeraddress

use after update trigger:

create trigger deleted_address on tblcustomer after update begin    set nocount on      if update (address)       update t set countprev = countprev + 1, oldaddress = d.address       tblcustomer t       join inserted on t.customer_id = i.customer_id       join deleted d  on t.customer_id = d.customer_id  end 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -