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 how to start it.
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 how 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>