AFTER INSERT TRIGGER ISSUE

Last Post 15 Aug 2008 06:29 AM by kjmcsd. 0 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
kjmcsd
New Member
New Member

--
15 Aug 2008 06:29 AM
OK I have the following trigger:

ALTER TRIGGER [dbo].[tr_AddressUpdate]
ON [dbo].[Customers]
AFTER INSERT,UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF (UPDATE(DistCity)) OR (UPDATE(DistState))
BEGIN
UPDATE Customers
SET Changed = 1
-- Insert statements for trigger here
END

END

I want to update a column (Changed) when I insert or update the city or state field with 1

This works for update but not when I do an insert. When I insert a new record it updates every record in the table.

What am I doing wrong? Please help. Thanks!


Acceptable Use Policy
---