first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

SQL Server 2005 t-SQL: Basic XQuery Example

DECLARE @x xml

SET @x = ' <root> <myElement myAttribute="attrValue">The element value.</myElement> </root> '

SELECT @x.query('//myElement/node()') as [element value] , @x.query('data(//myElement)') as [element value] , @x.query('data(//myElement/@myAttribute)') as [elment attribute]

/*

For more information see:

“Using the data() function in XQuery”
http://www.sqlskills.com/blogs/bobb/
    2004/09/06/UsingTheDataFunctionInXQuery.aspx

“Introduction to XQuery in SQL Server 2005”
http://technet.microsoft.com/en-us/library/ms345122.aspx

*/

mod date: 2007-12-10T23:57:56.000Z