Flo... there's a small error in your temporary stored procedure. It was leaving a leading space in the results. I've repaired it in the following but it still beats the tar out of the Tally table solution. Guess the Tally table pretty much sucks on the big stuff.
--===== Procedure to split line
IF (OBJECT_ID('tempdb..#usp_print_lines') IS NOT NULL)
DROP PROCEDURE #usp_print_lines
GO
CREATE PROCEDURE #usp_print_lines
@text NVARCHAR(MAX)
AS
DECLARE @ret TABLE (id INT IDENTITY, line NVARCHAR(MAX))
DECLARE @pos INT, @next INT, @crlf NCHAR(2)
SELECT @pos = 1, @crlf = CHAR(13) + CHAR(10)
WHILE (1 = 1)
BEGIN
SELECT @next = CHARINDEX(@crlf, @text, @pos)
IF (@next = 0) BREAK --- Nothing more to do
IF (@pos <> @next)
INSERT INTO @ret
SELECT SUBSTRING(@text, @pos + 1, @next - @pos -1)
SELECT @pos = @next + 1
END
SELECT line FROM @ret ORDER BY id --- Return lines
GO
--Jeff Moden
Change is inevitable... Change for the better is not.