TR_EVENT_MARKEVENTCONTACTASCONSTITUENT

Definition

Copy


                    CREATE trigger TR_EVENT_MARKEVENTCONTACTASCONSTITUENT 
                        on dbo.EVENT 
                        after insert 
                        not for replication
                    as begin
                        set nocount on;

                        declare @CURRENTDATE datetime = getdate();

                        if update(EVENTLOCATIONCONTACTID)
                        begin
                            update dbo.CONSTITUENT
                                set ISCONSTITUENT = 1,
                                    CHANGEDBYID = inserted.CHANGEDBYID,
                                    DATECHANGED = @CURRENTDATE
                            from inserted
                            where (CONSTITUENT.ID = inserted.EVENTLOCATIONCONTACTID) and
                                    (CONSTITUENT.ISCONSTITUENT = 0);
                        end
                    end