Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

56 Posts

Posted - 11/02/2012 :  22:35:02  Show Profile  Reply with Quote

I have data in one xml column

<Arrtibute Level="PR" name="ST" type="Include" Value="'CA','NY'" />
<Arrtibute Level="LN" name="LA" type="LessThan" Value="500000" />

I want to create function who return table in this format.

Level name type Value
PR ST include 'CA','NY'
LN LA LessThan 500000


Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/03/2012 :  08:38:12  Show Profile  Reply with Quote
You can wrap the query below into a function. You may get better performance if you directly used the query against your table(s) instead of wrapping them in functions.
<Arrtibute Level="PR" name="ST" type="Include" Value="''CA'',''NY''" />
<Arrtibute Level="LN" name="LA" type="LessThan" Value="500000" /> 

	c.value('@Level','varchar(32)') [Level],
	c.value('@name','varchar(32)') [name],
	c.value('@type','varchar(32)') [type],
	c.value('@Value','varchar(32)') [Value]
	@x.nodes('/LTW/Arrtibute') T(c);
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000