• The script you've posted doesn't even parse.

    Msg 102, Level 15, State 1, Line 37

    Incorrect syntax near ','.

    Msg 134, Level 15, State 1, Line 76

    The variable name '@THIS_CALENDAR_YR_START_DT' has already been declared. Variable names must be unique within a query batch or stored procedure.

    Msg 102, Level 15, State 1, Line 106

    Incorrect syntax near ','.

    Msg 156, Level 15, State 1, Line 74

    Incorrect syntax near the keyword 'DECLARE'

    It uses a lot of log space because you're doing a lot of inserts and deletes. Unless you can figure a way so that you don't need to insert so much and delete so much, you won't be able to do much about the log space.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass