• Try the following trigger in a test environment. You will need to update it as you didn't provide all the information needed (no definition for the second table (80 columns)). Also, be sure to note the comments where I modified or added code.

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER TRIGGER [Schema1].[Table1_STAT]

    ON [Schema1].[Table1]

    FOR UPDATE -- , INSERT, DELETE <- If you don't want this fired on INSERT or DELETE, don't include them

    AS

    BEGIN

    -- IF NOT UPDATE(MODDATE)

    -- UPDATE [Schema1].[Table1]

    -- SET MODDATE = GETDATE() -- why do this when you are going to delete immediately anyway

    -- WHERE LID IN (SELECT LID FROM inserted WHERE STATUS in ('C','X'))

    -- declare table variables to hold the values being archived

    declare @archive_table1 table (

    --columns for table 1

    )

    declare @archive_table2 table (

    --columns for table 2

    )

    ---Insert the C or X lead sheet to arch

    INSERT INTO [DB2].[dbo].[ArchTable2](

    [ROWID] ,

    [LID],

    [NAME],

    [TOTALCOUNT],

    [PID],

    [CID],

    [OID],

    [ADATE],

    [RDATE],

    [CDATE],

    [STAT] ,

    ,

    [REACH] ,

    [SA] ,

    [RED],

    [DK] ,

    [DATEINDB],

    [MODDATE],

    [TID]

    )

    output ( -- Output the rows to a table variable that are being archived

    [ROWID] ,

    [LID],

    [NAME],

    [TOTALCOUNT],

    [PID],

    [CID],

    [OID],

    [ADATE],

    [RDATE],

    [CDATE],

    [STAT] ,

    ,

    [REACH] ,

    [SA] ,

    [RED],

    [DK] ,

    [DATEINDB],

    [MODDATE],

    [TID]

    ) into @archive_table1

    SELECT

    [ROWID] ,

    [LID],

    [NAME],

    [TOTALCOUNT],

    [PID],

    [CID],

    [OID],

    [ADATE],

    [RDATE]

    [CDATE],

    [STAT] ,

    ,

    [REACH] ,

    [SA] ,

    [RED],

    [DK] ,

    [DATEINDB],

    GETDATE(), -- [MODDATE], <- Put the datetime here

    [TID]

    FROM

    inserted

    WHERE

    STAT in ('C','X')

    -- Insert the closed or disabled lead sheet associated leads to arch

    INSERT INTO [DB2].[dbo].[ARCHTable3]

    (80 Columns)

    output ( -- Output the rows to a table variable that are being archived

    80 columns

    ) into @archive_table2

    SELECT 80 columns

    FROM [Schema1].[Table2] A INNER JOIN inserted I

    ON A.[LID] = I.LID

    WHERE I.STAT in ('C','X')

    -- Delete all the closed or disabled lead sheets and leads after archiving

    DELETE FROM

    [Schema1].[Table2]

    FROM

    [Schema1].[Table2] t2

    inner join @archive_table2 at2

    on (t2.LID = at2.LID)

    DELETE FROM

    [Schema1].[Table1]

    FROM

    [Schema1].[Table1] t1

    inner join @archive_table1 at1

    on (t1.LID = at1.LID)

    END