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

sql server programming

group:

Parsing Large XML Strings


Parsing Large XML Strings Nickl
2/1/2005 11:01:02 PM
sql server programming: Can anyone tell me how to use the sp_xml_preparedocument to prepare a large
string dynamically. What I am trying to do is this;

-- Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, EXEC sp_executesql @sql

The tricky bit is the last argument which usually has a variable that holds
an XML string. I can't do this because my string is too big (>8000). I am
attempting to generate the string on the fly with the sp_execute statement (I
have also tried EXEC(@sql))

Does anyone know how to get a large string into the .._preparedocument
statement? or a suitable workaround?
My overall purpose is to pull my XML string back into relational format.
Any help will be much appreciated.
Thanks
Nick Lindner



-- Execute a SELECT statement using OPENXML rowset provider.
SELECT *
FROM OPENXML (@idoc, '/root/Customer/Order', 9)
WITH (id int '@mp:id',
oid char(5),
date datetime,
amount real,
parentIDNo int '@mp:parentid',
parentLocalName varchar(40) '@mp:parentlocalname')
EXEC sp_xml_removedocument @idoc
RE: Parsing Large XML Strings John Bell
2/2/2005 12:39:01 AM
Hi

If you pass the XML to a stored procedure then the parameter can be a text
datatype, otherwise you can use a text column in a table to construct it,
failing that materialise the XML in a file.

John

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