Update a table on Updating data in other table in SqlServer(After Update trigger)
Here if we update data in [TBL_PROSPECTDETAILS] table ..using this after update trigger we can update the data in TBL_ACORD_MISC.
After Update Trigger :
Create TRIGGER [dbo].[trgAfterUpdate] ON [dbo].[TBL_PROSPECTDETAILS]
after update
AS
Update TBL_ACORD_MISC set Company=i.NameofBusiness,ApplicantName=i.OwnerContact,CompOffPhone=i.Phone,
CompMobPhone=i.PayrollHRContact,CompMailingAddress=i.Address,CompCity=i.City,
CompState=i.State,CompZip=i.Zipcode,CompYRSinBus=i.YearofBusiness,CompSIC=i.SIC,
CompNAICS=i.PCompany,CompWebsite=i.URL,ComEmail=i.Email,CompCorporationType=i.CorpType,
CompFederalIDNum=i.FedTaxId from TBL_ACORD_MISC j join TBL_PROSPECTDETAILS i on j.PID=i.PId
Go
after update
AS
Update TBL_ACORD_MISC set Company=i.NameofBusiness,ApplicantName=i.OwnerContact,CompOffPhone=i.Phone,
CompMobPhone=i.PayrollHRContact,CompMailingAddress=i.Address,CompCity=i.City,
CompState=i.State,CompZip=i.Zipcode,CompYRSinBus=i.YearofBusiness,CompSIC=i.SIC,
CompNAICS=i.PCompany,CompWebsite=i.URL,ComEmail=i.Email,CompCorporationType=i.CorpType,
CompFederalIDNum=i.FedTaxId from TBL_ACORD_MISC j join TBL_PROSPECTDETAILS i on j.PID=i.PId
Go
No comments:
Post a Comment