• OK...I have fixed the bug and reposted the SQL as an update to this article. It's a very simple fix. Just remove the '+ 1' in Line 70 of the SQL that was posted previously. Here is the line of code with the problem area bolded and underlined:

    SET @SubstringEnd = LEN(@Chunk) - (CHARINDEX(CHAR(10), REVERSE(@Chunk))) + 1 --...AND STOP THE PRINT AT THE END OF THE PREVIOUS LINE.

    Thanks again for the feedback.

    SB