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
*/