开发者

Write stored procedure parameters to an XML Column

开发者 https://www.devze.com 2023-01-15 08:50 出处:网络
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.

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消