• Hello SSCrazy, I'd like to say thanks for the code.....I have been looking at it this morning and it is coming up with some errors in the OUTPUT section. These are:

    ISNULL(i200.[END DT], @strdt), -- The multi-part identifier "i200.END DT" could not be bound

    CASE WHEN i200.[END DT] IS NULL THEN '0' ELSE i200.QTY END, -- The multi-part identifier "i200.END DT" could not be bound

    Is the problem with the space in the column name, even though it has the square brackets around it, or are you not allowed to refer to this variable in the output section ??