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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Sql Server2005 and xml

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-14 : 08:37:06
Dharmarao writes "Hi
Am working on Sql server2005 My question is in my Database i have like 60 Tables and in one Table ihave a one column called xmldata(ntext,null) when i query this table on this xmldata column it showing me xml structure but iwant to make this xml structure imean wht ever the attributes and elements in this structure i want to retrieve them as columns in to my tables.Imean in to my database.plz me give me answer as soon as possible

thnk u"

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-02-14 : 15:06:11
First of all - one of the key new features in SQL Server 2005 is the XML data type. I'd suggest that you use it instead of ntext to store the XML.

Then, to read the XML, you can use the OPENXML function or just query the XML using one of the XML data type methods query or value.

See here for the relevant pages in Books Online
http://msdn2.microsoft.com/en-us/library/ms189887.aspx (xml data type)
http://msdn2.microsoft.com/en-us/library/ms191474.aspx (query method)
http://msdn2.microsoft.com/en-us/library/ms178030.aspx (value method)
http://msdn2.microsoft.com/en-us/library/ms186918.aspx (OPENXML function)

And for an overview of XML support in SQL Server 2005
http://msdn2.microsoft.com/en-us/library/ms345117.aspx
Go to Top of Page
   

- Advertisement -