AnsweredAssumed Answered

Trigger on A-table (versioned gdb) wont update (SQL server)

Question asked by Berelson on May 29, 2019
Latest reply on May 31, 2019 by bnayak-esristaff

I have a versioned GDB (SQL server) and set a trigger on A-table that is supposed to update a second A-table when a change (insert, update) is made.  I can see that the change is in the A-table (a225) where the trigger is set, but it doesnt seem to fire and make the change to a229.  I am editing on DEFAULT. Note I just added in "INSERT" to the AFTER UPDATE line.  I am actually altering code that I didnt write that is supposed to work on a non-versioned gdb but I need to replicate the database so had to version it and w/replication cant use move edits to base. So now have to rewrite the code to hit the a-tables. I dont think I'm supposed to set triggers on the _evw? This is all new to me so I appreciate any help/tips. 

 

USE [UWADMINGIS_INVISION]
GO
/****** Object: Trigger [dbo].[Building_Update_SHORTNAME_trg] Script Date: 5/29/2019 11:09:41 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

 

ALTER TRIGGER [dbo].[Building_Update_SHORTNAME_trg]
ON [dbo].[a225]
AFTER INSERT, UPDATE
AS
IF UPDATE (SHORTNAME)
BEGIN

UPDATE [dbo].[a229]
SET UW_Building_Name = BUILDING.SHORTNAME
FROM [dbo].[a229] f
LEFT OUTER JOIN (SELECT DISTINCT LOCATION_CODE FROM inserted) i ON f.Location_Code = i.LOCATION_CODE
LEFT OUTER JOIN (
SELECT LOCATION_CODE,
SHORTNAME
FROM a225
) BUILDING on BUILDING.LOCATION_CODE = f.Location_Code
WHERE i.Location_code IS NOT NULL

END

Outcomes