Is it possible to create an After Update trigger on table A that can gather both the delete and insert data for the After Update from columns A.1, A.2, A.3 when A.3 is updated to NULL? I need that plus the delete and insert data from columns B.1 and B.2 from table B as well when column A.3 is updated and set to NULL? I have the trigger below that will get me what I need from table A but is it possible to also get the data from table B from this trigger?
In other words, I'm trying to figure out how to populate the Table B OldWorkFlowStepId and NewWorkFlowStepid columns that are created in the CONTAINER_DEBUG table and declared as variables. The OldWorkFlowStepId value needs to be taken when the delete.CurrentStatusId is taken from the first table and the NewWorkflowStepId value needs to be taken when the insert.CurrentStatusId is taken from the first table.
How would I go about that? I am trying to troubleshoot a column that is getting set to NULL when it shouldn't and I'm trying to trap exactly where in the workflow this is happening.
DROP TABLE CONTAINER_DEBUG
CREATE TABLE CONTAINER_DEBUG
( ContainerId CHAR(16)
,LastActivityDate DATETIME )
DROP TRIGGER CONTAINER_TRG_BU
CREATE TRIGGER CONTAINER_TRG_BU
IF ( UPDATE (CurrentStatusId) )
DECLARE @OldCurrentStatusId CHAR(16);
DECLARE @NewCurrentStatusId CHAR(16);
DECLARE @OldLastCompletedTaskId CHAR(16);
DECLARE @NewLastCompletedTaskId CHAR(16);
DECLARE @OldWorkflowStepId CHAR(16);
DECLARE @NewWorkflowStepId CHAR(16);
IF ( ISNULL(@OldCurrentStatusId,'XXX') <> 'XXX' AND
ISNULL(@NewCurrentStatusId,'XXX') = 'XXX' )
INSERT INTO CONTAINER_DEBUG ( ContainerId
FROM Inserted i INNER JOIN Deleted d ON i.ContainerId = d.ContainerId
RAISERROR ('CurrentStatusId is set to NULL - Aborting...', 16, 10);