I have a table called "T" and a column in that "C" which is of type TEXT. Now "C" holds a lot of name-value pairs, which I need to parse into name and values.

I am doing the following:

declare @textptr varbinary(16)
declare @namevaluepair varchar(8000)

DECLARE loop_data CURSOR
FOR
select TEXTPTR(C)
from T

OPEN loop_data
FETCH NEXT FROM loop_data INTO @textptr

WHILE @@FETCH_STATUS = 0
BEGIN
READTEXT T.C @textptr 0 50

FETCH NEXT FROM loop_data INTO @textptr
END

CLOSE loop_data
DEALLOCATE loop_data

As you can see, after I use the macro READTEXT in the cursor loop, is there any way I can put that in a local variable so that I can manipulate it like a varchar? Something like

SET @namevaluepair = READTEXT T.C @textptr int1 int2. Of course, when I do that it gives me errors.

Any ideas will be appreciated.

Thanks.