PFEDynamics / DynamicsPerf

DynamicsPerf is a performance analysis tool for Microsoft Dynamics AX
Microsoft Public License
75 stars 20 forks source link

bug in 1-Create_core_objects.sql script with Ax_Batch_History purge script - MISSING ELSE #15

Closed Pierre-Louis-LSP closed 4 years ago

Pierre-Louis-LSP commented 4 years ago

IF @C_TABLE_NAME IN ('AX_BATCH_HISTORY') --RETAINED BASED ON FIELDS IN THE DATABASES_2_COLLECT TABLE

    BEGIN
    DELETE QS FROM AX_BATCH_HISTORY QS WITH (ROWLOCK, READPAST) 
        INNER JOIN DATABASES_2_COLLECT DC ON QS.SERVER_NAME = DC.LINKED_SERVER AND DC.DATABASE_NAME = QS.DATABASE_NAME
    WHERE  QS.SERVER_NAME = @SERVER_NAME AND QS.DATE < DATEADD(MONTH,DC.RETAIN_HISTORY_MONTHS * -1, GETDATE()) AND QS.FLAG = 'M'

                    SET @ROW_COUNT = @ROW_COUNT + @@ROWCOUNT

                --REH DELETE DAYS TOTALS FROM QUERY_HISTORY     
    DELETE QS FROM AX_BATCH_HISTORY QS WITH (ROWLOCK, READPAST) 
        INNER JOIN DATABASES_2_COLLECT DC ON QS.SERVER_NAME = DC.LINKED_SERVER AND DC.DATABASE_NAME = QS.DATABASE_NAME
    WHERE  QS.SERVER_NAME = @SERVER_NAME AND QS.DATE < DATEADD(MONTH,DC.RETAIN_HISTORY_MONTHS * -1, GETDATE()) AND QS.FLAG = 'D'

                    SET @ROW_COUNT = @ROW_COUNT + @@ROWCOUNT

    END

ELSE -- !!!! THIS ELSE statement is missing in original script ,causing some PURGE statements to fail

IF @C_TABLE_NAME IN ('INDEX_HISTORY', 'QUERY_HISTORY') --RETAINED BASED ON FIELDS IN THE DATABASES_2_COLLECT TABLE