Forums

This topic is locked

MSSQL 6.5: Split text field into varchar(255)

Posted 19 Sep 2001 12:15:23
1
has voted
19 Sep 2001 12:15:23 Joris van Lier posted:
Hi peeps, i'm trying to save the contents of an E-mail into a text-field in SQL 6.5. The e-mail should be sent by JMail, via a scheduled stored procedure (Job mailing).

My problem is: How do i split the contents of a 8k text-field into multiple [var]char(255) strings, so i can manipulate the data, and send it to the Jmail component.

Here's what i've got so-far: i've managed to do a READTEXT for each 255 chars, but can't figure out how to get those 255 characters into a variable or temporary Table.

<pre id=code><font face=courier size=2 id=code>
DECLARE @ptrval binary(16), @dLen int, @charAt int, @charsLeft int, debug varchar(255)
SELECT @ptrval = TEXTPTR(TEXT_body) FROM table
SELECT @dLen = DATALENGTH(TEXT_body)FROM table
SELECT @charAt = 0
SELECT @charsLeft = @dLen
WHILE (@charAt &lt; @dLen)
BEGIN
SELECT @charAt = (@charAt + @charsLeft)
IF((@dLen - @charAt) &gt; 255)
BEGIN
SELECT @charsLeft = (@dLen - (@charAt + 255) )
END
ELSE
BEGIN
SELECT @charsLeft = (@dLen - (@charAt) )
END


SELECT @Debug = 'DEBUG charAt:' + CONVERT(varchar(255), @charAt)
PRINT @Debug
SELECT @Debug = 'DEBUG charsLeft:' + CONVERT(varchar(255), @charsLeft)
PRINT @Debug
SELECT @Debug = 'DEBUG currSel:' + CONVERT(varchar(255), @String)
PRINT @Debug
READTEXT #TempMailSQL.TEXT_body @ptrval @charAt @charsLeft
END
</font id=code></pre id=code>


WhizzrD

Edited by - whizzrd on 09/19/2001 12:19:27

Reply to this topic