I have a database view which pulls records from a table in an external database. How do I detect record change in the view? I have created an "Instead Of" trigger on the view and it never get fired. I can't create the trigger on the source table. Below is the code, but never runs. What to change to detect record change?
ALTER TRIGGER [dbo].[trigger_A]
ON [dbo].[view_MORTST_ICILOC]
instead of INSERT,UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @ITEM as varchar(24);
declare @QtyOnHand as decimal(19,4);
select @ITEM = i.ITEMNO from inserted i;
select @QtyOnHand = i.QTYONHAND from inserted i;
insert into ITEM_CHANGE (ITEM, QTYONHAND, DT) values (@ITEM, @QtyOnHand, getdate())
END
go
Thanks in advance.
ALTER TRIGGER [dbo].[trigger_A]
ON [dbo].[view_MORTST_ICILOC]
instead of INSERT,UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @ITEM as varchar(24);
declare @QtyOnHand as decimal(19,4);
select @ITEM = i.ITEMNO from inserted i;
select @QtyOnHand = i.QTYONHAND from inserted i;
insert into ITEM_CHANGE (ITEM, QTYONHAND, DT) values (@ITEM, @QtyOnHand, getdate())
END
go
Thanks in advance.