Write stored procedure parameters to an XML Column
I have a need to take the parameters passed in to a Stored Procedure (SQL 2005) and write those values into an XML column as one xml document.
Looking for an idea on h开发者_JAVA技巧ow to start it.
Well, let's do this thing!
select 1 [one],2 [two],3 [three]
from (select null dummy) t
for xml auto
and we get
<t one="1" two="2" three="3" />
Neat, eh?
You can also experiment with for xml path like so:
select 1[one],2[two],3[three]
from (select null dummy) t
for xml path('foo')
And the result is:
<foo>
<one>1</one>
<two>2</two>
<three>3</three>
</foo>
精彩评论