all groups > sql server programming > december 2005 >
You're in the

sql server programming

group:

Appending Text to a SQL Text Data Type


Re: Appending Text to a SQL Text Data Type Dan Guzman
12/31/2005 2:38:05 PM
sql server programming:
[quoted text, click to view]

How are you determining this? What does 'SELECT DATALENGTH(TextField) FROM
#tempTrigger' return?

--
Happy Holidays

Dan Guzman
SQL Server MVP

[quoted text, click to view]

Appending Text to a SQL Text Data Type bobnunny
12/31/2005 8:19:59 PM
I am trying to use a cursor to create a mass Text field with the results from
the selections from a series of VarChar(8000) values. I know I need to use
UpdateText, but it only seems to store the 1st one it reads. Can anyone help?
Here's my text:

Declare @TriggerText nVarChar(4000)
Declare @ptrval Binary(16)
Declare @Offset Int

-- Create temporary table to hold Text field
Create Table #tempTrigger
(TextField Text NULL)
Insert Into #tempTrigger Select ''

-- Get Trigger "basis"
Declare curTriggerBasis Insensitive Cursor For
Select c.Text
From sysObjects o (nolock)
Inner Join sysComments c (nolock)
On o.ID = c.ID
Where o.Name = 'cttx_Customer'
Order By ColID
For Read Only
Open curTriggerBasis
Fetch Next From curTriggerBasis Into @TriggerText
While @@Fetch_Status = 0
Begin
Select @ptrval = TEXTPTR(TextField),
@Offset = DataLength(TextField)
From #tempTrigger (nolock)
UpdateText #tempTrigger.TextField @ptrval @Offset 0 @TriggerText
Fetch Next From curTriggerBasis Into @TriggerText
End
Close curTriggerBasis
Deallocate curTriggerBasis

Re: Appending Text to a SQL Text Data Type bobnunny
12/31/2005 10:20:14 PM
I've put Print statements in there to check this out. It shows Datalength as
4000 everytime except the last one. BUT, like an idiot I was checking the
loop so hard, but the Select statement at the end will only return the first
4000. Once I changed that to DataLength, it showed it had it all.

Thanx!

[quoted text, click to view]
AddThis Social Bookmark Button