|
|
Question : Problems passing a long XML string to OPENXML using sp_xml_preparedocument.
|
|
I have to parse some data using OPENXML, the problem is that the XML may exceed the 8000 character limit of the TSQL varchar variable size. The documentation for sp_xml_preparedocument says it can accept the TEXT datatype, but I can't figure out how to feed it in? I am currently using the following code (with the varchar variable) which works as long as the XML doesn't exceed 8000 characters.
Declare @Handle1 as int Declare @XMLData1 as varchar(8000) Select @XMLData1 = dbo.tbl_Documents.DocTxt From dbo.tbl_Documents Where dbo.tbl_Documents.DocID = 11320 /* NOTE: dbo.tbl_Documents.DocTxt is a field of data type of TEXT containing a well formed XML document. */ Exec sp_xml_preparedocument @Handle1 OUTPUT, @XMLData1 Select * From openxml (@Handle1, ... Exec sp_xml_removedocument @Handle1
I tried the following, but the parser in Query Analyzer complained.
Declare @Handle1 as int Exec sp_xml_preparedocument @Handle1 OUTPUT, Select @XMLData1 = dbo.tbl_Documents.DocTxt From dbo.tbl_Documents Where dbo.tbl_Documents.DocID = 11320 Select * From openxml (@Handle1, ... Exec sp_xml_removedocument @Handle1
How do I provide sp_xml_preparedocument with XML containing more that 8000 characters?
|
Answer : Problems passing a long XML string to OPENXML using sp_xml_preparedocument.
|
|
One other approach you could look into is the SP_OA ectended stored procedures. You may (I have never done it) be able to use these to load the XML document using the XMLDOM and extract the relevant values. Caveat: In that case, you would not be able to use sp_xml_preparedocument, OpenXML or sp_xml_removedocument.
|
|
|
|
|