Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 exploding xml table in ntext field

Author  Topic 

jeffiec
Starting Member

1 Post

Posted - 2010-06-03 : 17:18:26
I am trying to explode some data from an ntext field into a cvs for import, here is what i have so far,
DECLARE @XML as XML
DECLARE @hDoc as INT
SET @XML = (SELECT billaddress FROM order WHERE id=7 )
exec sp_xml_prepairedocument @hDoc OUTPUT, @XML

SELECT firstname
FROM OPENXML (@hDoc, '//')
WITH (type text './type/@text',
FirstName text './FirstName/@text')
exec sp_xml_removedocument @hDoc OUTPUT
i only entered 1 field for test but will include more later on, any help apreciated, thanks in advance. Jeff

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-06-05 : 06:51:32
are you using sql 2005 or more. then you can use xml datatype and use functions like nodes(),query() etc to get data from xml

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -