Fix the INSERT statement and re-try your script:
INSERT INTO #CommentsTable (ID, Comments)
VALUES (1, REPLICATE(cast('A' as varchar(max)), 280000));
Also try an alternative:
;
with Q as
(
select ID, PartID = 1, CommentPart = substring(Comments, 1, @ChunkSize), i = @ChunkSize + 1
from #CommentsTable
union all
select c.ID, PartID + 1, substring(c.Comments, i, @ChunkSize), i + @ChunkSize
from #CommentsTable c
inner join Q on Q.ID = c.ID
where i <= len(c.Comments)
)
select ID, PartID, CommentPart
from Q
order by ID, PartID
option (maxrecursion 0)