USE [UFDATA_001_2017]GO /****** OBJECT:  TRIGGER [DBO]. [jds_customer_updatecity] script date: 07/06/2018 16:53:04 ******/ set ansi_nulls ongo set quoted_identifier ongo create trigger [ DBO]. [Jds_customer_updatecity] on [dbo]. [Customer] for insert, delete ,update (remove, otherwise will be error nested layer number not exceeding) not for replicationas beginset nocount on; --premise: The city names in the regional archives must be standardized--get the region code from the customer file, get the city declare @CUScode varchar from the regional classification declare @ City varchar (declare @cProvince varchar) select @CUScode =ccuscode from inserted select @city =cdcname from districtclasswhere cdccode = (select cdccode from customer where [email protected]) --from the provincial table to get the province select @cPrOvince=vsimplename from hr_ct007 where ccodeid = (Select distinct cpcodeid from hr_ct007where ilevels in (1) and vdescription like '% ' [email protected]+ '% ') --last updated the provinces and cities in the customer profile update customerset [email protected],[ email protected]where [email protected] set nocount off; end go
SQL triggers: Automatically update the provinces and cities in the contact page based on the region information in the customer profile