Thursday 15 July 2010

Query Xml in SQL Server 2008 R2 -


I'm new to SQL Server and T SQL, How can I ask information stored in this XML in SQL Server 2008 R2 ?

XML:

  & lt; Smp: root xmlns: smp = "http: // tempuri.org/smp.xsd" header = "test title" & gt; & Lt; SMP: Section & gt; & Lt; Smp: G3 idnumber = "01" & gt; & Lt; SectionHost & gt; ABC & lt; / SectionHost & gt; & Lt; / SMP: G3 & gt; & Lt; Smp: G2 idnumber = "01" & gt; & Lt; SectionHost & gt; Def & lt; / SectionHost & gt; & Lt; / SMP: G2 & gt; & Lt; / SMP: Section & gt; & Lt; / SMP: Root & gt;    

If you have Xml stored in a Use the XML column from the value method to china to Xml .

Next try and post

  with XMLNAMESPACES (with the default 'http') some  DDL, DML  let us do what you do Try to show your table structures etc.  

: //tempuri.org/smp.xsd ') SELECT a.value (' Header ',' Navratra (50) ') Header form In, b. The value ('local-name (.)', 'Narretar (50)'), in the form, b. X.AXmlColumn.nodes ('root' as applied to x cross as valid as 'Idnumber,' b.value ('.', 'Nvarchar (20)') as the value ('idnumber', 'int') ') A (A) cross a. Some useful links for implementing nodes ('section / *') b (b)

Start:



No comments:

Post a Comment