troubleshooting Question

Error when creating an UPDATE Trigger in SQL

Avatar of skull52
skull52Flag for United States of America asked on
Microsoft SQL ServerMicrosoft Dynamics
6 Comments1 Solution166 ViewsLast Modified:
I am trying to create a trigger on a table (RM00102) when Column (USERDEF1) is updated so it will add the current date to Table (SSGRM001) column (CustUpdDate). but when I fire the trigger with a change to USERDEF1 i get the following error
"a save operation on table RM_Customer_MSTR_ADDR failed because a database constraint was violated"

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [dbo].[trg_SSGRM001_CUSTUPD] ON [dbo].[RM00102] 
	AFTER UPDATE 
AS 
set nocount on 
IF UPDATE(USERDEF1)
BEGIN 
UPDATE D
SET D.CustUpdDate = GETDATE() 
FROM   RM00102 A INNER JOIN
SSGRM001 D ON A.CUSTNMBR = D.CUSTNMBR 
END 
set nocount off
GO
ASKER CERTIFIED SOLUTION
JesterToo

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros