标签:insert 更新 编码 信息 tom sele simple tcl null
USE [UFDATA_001_2017] GO /****** Object: Trigger [dbo].[JDS_Customer_UPDATECITY] Script Date: 07/06/2018 16:53:04 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TRIGGER [dbo].[JDS_Customer_UPDATECITY] ON [dbo].[Customer] FOR INSERT, DELETE ,UPDATE(去掉,否则会报错嵌套层数不超过32) NOT FOR REPLICATION AS BEGIN SET NOCOUNT ON; --前提:地区档案里的城市名称必须规范统一 --从客户档案里获取地区编码,从地区分类里获取城市 declare @CUScode varchar(20) declare @city varchar(20) declare @cProvince varchar(20) select @CUScode=ccuscode from inserted select @city=cDCName from DistrictClass where cDCCode = (select cdccode from customer where cCusCode=@CUScode) --从省份表里获取省份 select @cProvince=vsimplename from HR_CT007 where ccodeID =( select distinct cpCodeID from HR_CT007 where ilevels in(1) and vdescription like '%'+@city+'%') --最后更新客户档案里的省份和城市 update customer set cProvince=@cProvince,cCity=@city where cCusCode=@CUScode SET NOCOUNT OFF; END GOSQL触发器:根据客户档案中的地区信息自动更新联系页中的省份和城市
标签:insert 更新 编码 信息 tom sele simple tcl null
原文地址:http://blog.51cto.com/13866219/2140895