Monday, November 14, 2011

Dynamics GP - SQL Trigger - Create a trigger to update RM00101 with last payment date from RM00103

USE [AW]
GO

/****** Object:  Trigger [LastPmtDate]    Script Date: 11/14/2011 14:59:33 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[trg_LastPmtDate]'))
DROP TRIGGER [dbo].[trg_LastPmtDate]
GO

USE [AW]
GO

/****** Object:  Trigger [dbo].[LastPmtDate]    Script Date: 11/14/2011 14:59:34 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [dbo].[trg_LastPmtDate]
   ON  [dbo].[RM00103]
   AFTER INSERT,UPDATE
AS
BEGIN
SET NOCOUNT ON;

update RM00101 set RM00101.CCRDXPDT = inserted.LASTPYDT
from INSERTED
where RM00101.CUSTNMBR = inserted.custnmbr


END

GO

1 comment: