Trigger doesn't seem to work

  • I have a trigger that executes an insert into a table with the primary key, previous value, current value, and the Getdate() as a modified date. There are several (100 +) "if statements" in the trigger checking to see if each column in the table is updated. If the column was updated it gets inserted into the table else it doesn't. It works fine with updating one record but when I update say 30,000 rows it doesn't. Below is the code for my trigger. Why is it not working how I want it to when I have a large update?

    Use MyDatabase

    GO

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    Create TRIGGER [dbo].[MyTrigger] ON [dbo].[MyTable]

    AFTER UPDATE

    AS

    SET NOCOUNT ON

    Declare @Column_Updated varchar(400),

    @MCRID as int,

    @Previous_Value varchar(400),

    @New_Value varchar(400)

    IF ( UPDATE([100_P_NUQA]) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'100_P_NUQA'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ACA_ExportID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ACA_ExportID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ACA_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ACA_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ASM_EDPS_DELETE_ExportID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ASM_EDPS_DELETE_ExportID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ASM_ExportID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ASM_ExportID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ATT_FLAG) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ATT_FLAG'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(C_RX_B_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'C_RX_B_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(C_RX_C_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'C_RX_C_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(C_RX_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'C_RX_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(C_V12_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'C_V12_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(C_V22_B_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'C_V22_B_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(C_V22_C_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'C_V22_C_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(C_V22_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'C_V22_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CAPITATED) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CAPITATED'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CHART_FINDER_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CHART_FINDER_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CHART_SCORE_GROUP) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CHART_SCORE_GROUP'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODE_QA_SUBMIT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODE_QA_SUBMIT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODED_2X) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODED_2X'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODED_2X_V12) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODED_2X_V12'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODED_2X_V22) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODED_2X_V22'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODED_2X_V22_B) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODED_2X_V22_B'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODED_2X_V22_C) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODED_2X_V22_C'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODED_ON) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODED_ON'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODER_USER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODER_USER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CODER_USERID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CODER_USERID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CR_CONTACT_FIRST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CR_CONTACT_FIRST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(CR_CONTACT_LAST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'CR_CONTACT_LAST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(DOS) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'DOS'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(DOS_FROM_DT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'DOS_FROM_DT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(DOS_THRU_DT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'DOS_THRU_DT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(DX_KEY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'DX_KEY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EDPS_ExportID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EDPS_ExportID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EMPLOYEE_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EMPLOYEE_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ENC_KEY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ENC_KEY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ENC_PROV_MODIFY_DT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ENC_PROV_MODIFY_DT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO1) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO1'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO2) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO2'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO3) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO3'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO4) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO4'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO5) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO5'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO6) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO6'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO7) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO7'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO8) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO8'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(EO9) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'EO9'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(FACILITY_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'FACILITY_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_BUS_FUNC_STATUS) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_BUS_FUNC_STATUS'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_BUSINESS_SEGMENT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_BUSINESS_SEGMENT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_BUSS_FUNC_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_BUSS_FUNC_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_CLIENT_CD) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_CLIENT_CD'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_CONT_BUS_FUNC_INSTRUCTION) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_CONT_BUS_FUNC_INSTRUCTION'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_HP_PRODUCT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_HP_PRODUCT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_ITERATION) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_ITERATION'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_MEDICAL_RECORD_TYPE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_MEDICAL_RECORD_TYPE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_PROJ_CONTENT_BARCODE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_PROJ_CONTENT_BARCODE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_PROJ_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_PROJ_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_PROJECT_CONTENT_KEY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_PROJECT_CONTENT_KEY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_PROJECT_YEAR) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_PROJECT_YEAR'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GCM_PROV_GRP_ID_TYPE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GCM_PROV_GRP_ID_TYPE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GLB_MBR_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GLB_MBR_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(GROUP_TIN) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'GROUP_TIN'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HAWKEYE_DELETE_ExportID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HAWKEYE_DELETE_ExportID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HAWKEYE_ExportID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HAWKEYE_ExportID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_CMS) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_CMS'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_RX) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_RX'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_RX_B) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_RX_B'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_RX_C) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_RX_C'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_V12) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_V12'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_V22) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_V22'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_V22_B) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_V22_B'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HCC_V22_C) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HCC_V22_C'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HIC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HIC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HP_CD) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HP_CD'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HP_CD2) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HP_CD2'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(HP_MBR_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'HP_MBR_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ICD_DX_CD) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ICD_DX_CD'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ICD_VER_FLAG) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ICD_VER_FLAG'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(INSERT_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'INSERT_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(IS_INACTIVE_ENC_DX_SW) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'IS_INACTIVE_ENC_DX_SW'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(IS_INACTIVE_ENC_SW) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'IS_INACTIVE_ENC_SW'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(LOB) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'LOB'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MASTER_CODING_RESULTS_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MASTER_CODING_RESULTS_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MBR_DOB) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MBR_DOB'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MBR_FIRST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MBR_FIRST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MBR_LAST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MBR_LAST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MBR_MIDDLE_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MBR_MIDDLE_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MEMBER_CONTRACT_NUMBER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MEMBER_CONTRACT_NUMBER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MEMBER_GENDER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MEMBER_GENDER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MODIFIED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MODIFIED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(MS_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'MS_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NPI_RECEIVED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NPI_RECEIVED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NPI_SENT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NPI_SENT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_ACA_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_ACA_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_ACA_DROPPED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_ACA_DROPPED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_ACA_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_ACA_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_ACA_SNAPSHOT_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_ACA_SNAPSHOT_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V12_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V12_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V12_DROPPED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V12_DROPPED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V12_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V12_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V12_SNAPSHOT_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V12_SNAPSHOT_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_B_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_B_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_B_DROPPED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_B_DROPPED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_B_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_B_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_B_SNAPSHOT_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_B_SNAPSHOT_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_C_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_C_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_C_DROPPED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_C_DROPPED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_C_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_C_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_C_SNAPSHOT_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_C_SNAPSHOT_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_DROPPED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_DROPPED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_HCC) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_HCC'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(NU_V22_SNAPSHOT_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'NU_V22_SNAPSHOT_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(OFFSHORE_REST) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'OFFSHORE_REST'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(OPTUM_TIER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'OPTUM_TIER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(ORG_LOCATION) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'ORG_LOCATION'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PAGE_COUNT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PAGE_COUNT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PAGE_NUMBER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PAGE_NUMBER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PBP) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PBP'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROJECT_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROJECT_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_ADDRESS_1) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_ADDRESS_1'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_ADDRESS_2) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_ADDRESS_2'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_CITY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_CITY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_FIRST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_FIRST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_GRP_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_GRP_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_GRP_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_GRP_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_LAST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_LAST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_MIDDLE_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_MIDDLE_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_NPI) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_NPI'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_OFFICE_GRP_FIRST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_OFFICE_GRP_FIRST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_OFFICE_GRP_LAST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_OFFICE_GRP_LAST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_PHONE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_PHONE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_SPECIALITY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_SPECIALITY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_STATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_STATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROV_ZIP) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROV_ZIP'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROVIDER_CONTACT_PHONE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROVIDER_CONTACT_PHONE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROVIDER_EMAIL) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROVIDER_EMAIL'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROVIDER_FAX) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROVIDER_FAX'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROVIDER_SPECIALITY_CODE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROVIDER_SPECIALITY_CODE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROVIDER_TIN) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROVIDER_TIN'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(PROVIDER_TYPE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'PROVIDER_TYPE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(QA_RECEIVED_DATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'QA_RECEIVED_DATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(QA_RESULT) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'QA_RESULT'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(QA_SAVE_SUBMITTED) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'QA_SAVE_SUBMITTED'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(QA_SUBMITTED) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'QA_SUBMITTED'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(QA_USER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'QA_USER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_HP_PROV_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_HP_PROV_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_ADDRESS_1) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_ADDRESS_1'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_ADDRESS_2) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_ADDRESS_2'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_CITY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_CITY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_FED_TAX_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_FED_TAX_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_FIRST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_FIRST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_LAST_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_LAST_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_MIDDLE_INITIAL) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_MIDDLE_INITIAL'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_NPI) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_NPI'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_PHONE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_PHONE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_STATE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_STATE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REND_PROV_ZIP) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REND_PROV_ZIP'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(RET_PROVIDER) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'RET_PROVIDER'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(RETRIEVAL_PROV_FLAG) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'RETRIEVAL_PROV_FLAG'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REVIEW_TYPE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REVIEW_TYPE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(REVIEW_TYPE_MOD) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'REVIEW_TYPE_MOD'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(SLR_ELIGIBLE) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'SLR_ELIGIBLE'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(SLR_ELIGIBLE_CLOSED) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'SLR_ELIGIBLE_CLOSED'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(SOURCE_SYSTEM_PROV_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'SOURCE_SYSTEM_PROV_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(SUPP_RETRIEVAL_VENDOR) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'SUPP_RETRIEVAL_VENDOR'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(TABLE_RUN_LOG_ID) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'TABLE_RUN_LOG_ID'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(VENDOR_NAME) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'VENDOR_NAME'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(WORK_LIST_PARENT_ACTIVITY_KEY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'WORK_LIST_PARENT_ACTIVITY_KEY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    IF ( UPDATE(WORK_LIST_PARENT_ACTIVITY_KEY) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    VALUES

    (@MCRID

    ,'WORK_LIST_PARENT_ACTIVITY_KEY'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)

    END

    GO

  • as a general rule, if you've deflared @variables, you made a mistake in a trigger, and are limiting yourself to single row data instead if set based.

    the issue is your INSERT...VALUES.

    IF ( UPDATE([100_P_NUQA]) )

    BEGIN

    Select @MCRID = d.Master_Coding_Results_ID, @Previous_Value = d.QA_Result

    from deleted d

    Select @New_Value = i.QA_Result from Inserted i

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    [highlight="#ffff11"] VALUES

    (@MCRID

    ,'100_P_NUQA'

    ,@Previous_Value

    ,GetDate()

    , @New_Value)[/highlight]

    END

    it's probably like this, but the Primary key of your table was not obvious at first glance.

    IF ( UPDATE([100_P_NUQA]) )

    BEGIN

    INSERT INTO [dbo].[G_Column_Update_History]

    ([Master_Coding_Results_ID]

    ,[Column_Updated]

    ,[Previous_Value]

    ,[Date_Updated]

    ,[Current_Value])

    SELECT D.Master_Coding_Results_ID,

    ,'100_P_NUQA'

    ,D.[100_P_NUQA]

    ,GetDate()

    , I.[100_P_NUQA]

    FROM INSERTED I

    INNER JOIN DELETED D

    ON I.PKID = D.PKID

    END

    having said that, it's much, much easier to just store ALL changes, in a single row, instead of splitting it out the way you are now,,but if you are stuck with a pre-existing design pattern, i'll feel a bit sorry for you.

    the UPDATED function just tests if the columns were referenced int he query, and not whether the column changed.

    probably fine for what you are doing, but splitting a single row update to have as many extra inserts as there are columns is a possible performance hit .

    every row is going to insert

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • dndaughtery (3/3/2016)


    I have a trigger that executes an insert into a table with the primary key, previous value, current value, and the Getdate() as a modified date. There are several (100 +) "if statements" in the trigger checking to see if each column in the table is updated. If the column was updated it gets inserted into the table else it doesn't. It works fine with updating one record but when I update say 30,000 rows it doesn't. Below is the code for my trigger. Why is it not working how I want it to when I have a large update?

    Your trigger needs a complete rewrite. It is using scalar variables and assumes there is only 1 row in the inserted and deleted tables. This is NOT the case. Triggers fire once per operation and those tables contain all rows at once. Your trigger logic needs to be set based instead of scalar value based.

    You have some other major issues going on in here. Your audit table is an EAV style audit. This is extremely problematic for multiple reasons. The first is the performance of auditing is going to suffer horribly because you have to insert for each column. This slows everything down and it is a real mess to maintain. The second issue is the integrity of your audit data is incredibly challenging. Think about how hard it is to put together what a row looked like on a given date. You have to piece it together over all the rows in the audit table for each column. Last but not least, you are storing the audit for every single column in the update statement on every single update even if the value doesn't change.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Just to reinforce how bad this logic flaw is, I had a client GO OUT OF BUSINESS because they did this - and I TOLD THEM IT WAS GOING TO HAPPEN well before it did!

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply