I have a very simple xml that I pass to a sql sproc as a parameter. But for simplicity I pres开发者_JS百科ent it in declare.
declare @a xml;
set @a='<items>
<item>1</item>
<item>3</item>
<item>5</item>
<item>7</item>
</items>';
How do I convert this list to a table so I could make joins, etc. Basicly, How do I retrieve a table in the following form:
item
----
1
3
5
7
Thank you!
You could use the nodes
function:
select items.item.value('.','int')
from @a.nodes('items/item') as items(item)
精彩评论