SQLXML sample Codings

How to get all subelements of an XML Node in Sql Server 2005?

SELECT Sub.query('Cat/Sub/Values')

FROM sampleTable where Condition


Result ..


<Values>Karaikudi</Values>

<Values>Pallathur</Values>

<Values>Manachai</Values>







Main


How to extract particular ElementString of an XML in SQL Server 2005?

SELECT Cat.value('(/Cat/Main/Values)[2] ',

'varchar(50)' )

FROM sampleTable where Condition



Result --- Cities

No comments: