Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to store more than 8000 characters in a variable

Status
Not open for further replies.

vibs

Technical User
Sep 28, 2002
3
DK
This is the stored procedure I wrote but the limitation is if the XML returned to me is more than 8000 characters, the XML gets truncated. Is there a way around this limitation?

Many Thanks

CREATE PROCEDURE DBO.SV_JobDetailAddl4XML
(
@TransID INT
)
AS

BEGIN

declare @xmltext varchar(8000)
declare @FirstGT INT
declare @LastLT INT
declare @CurrLT INT
DECLARE @Root Varchar(50)

Set @Root = 'AdditionalDetail'

select @xmltext = (SELECT Cast(TR.XmlText as varchar(8000)) FROM Transactions TR
WHERE TR.TransactionID = @TransID)
set @firstGT = CHARINDEX('>',@XMLTEXT)
set @CurrLT = CHARINDEX('<',@XMLTEXT,@firstGT)
while (@CurrLT > 0)
Begin
set @LastLT = @CurrLT
set @CurrLT = CHARINDEX('<',@XMLTEXT, @LastLT+1)
End

set @xmltext = '<' + @Root + '>'
+ substring(@xmltext, @firstGT+1,@LastLT - @firstGT-1)
+ '</' + @Root + '>'
select @xmltext

END
 
Nope. &quot;A variable cannot be of text, ntext, or image data type.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top