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
 Need to insert the values from column datatype XML

Author  Topic 

chennaraaj
Starting Member

17 Posts

Posted - 2013-12-20 : 06:27:11
Hi All,

I am having Test table with (id int , DataDescription xml) . I need to read the values from DataDescription column and insert into one table

regards
rk

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-12-20 : 10:31:56
Post a representative sample of the data from the DataDescription column, and the values/columns you want to extract from it.

Typically you would query the XML to get the values via a select query which makes use of XML nodes function, and value and/or query functions. But, how you would write that largely depends on the nature of the XML data. Hence the need for a sample.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-21 : 00:52:56
Something like this

INSERT Table2
SELECT t.u.value('ElementName','datatype'),
...
FROM Table1 t
CROSS APPLY DataDescription.nodes('/<RootNodeName>/<FullPathOfNodes>')t(u)


the root name element name etc will depend on your actual xml value. if you can post a sample value we cant help out with actual query.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -