从存储过程输出中获取XML [英] Get XML from stored procedure output

查看:150
本文介绍了从存储过程输出中获取XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经存储了更新数据的过程.在更新之前,需要调用另一个SP并将这些结果转换为XML,然后使用该数据更新表.我可以使用FOR XML修改SP以提供XML结果,但在应用程序中使用相同的SP.如何将SP输出转换为XML格式.

I have stored procedure to update data. Before updation need to call another SP and convert those results into XML then update table with that data. I can modify SP to give XML result using FOR XML but same SP is used in application. How can I convert SP output into XML format.

推荐答案

一些随机的想法(这里只是袖手旁观):

1)复制存储过程,并将FOR XML添加到return语句中(不是很漂亮,但是可以使用).

2)让第二个存储过程调用非XML版本,然后使用FOR XML返回结果.

3)在存储过程的SELECT语句中构建XML.

我可能会建议先尝试#2,因为这似乎是最干净的方法,但它们只是您需要充实并了解哪种方法最适合您的问题和应用程序的想法.

享受吧.
A couple random ideas (just off the cuff here):

1) Duplicate the stored procedure and add the FOR XML to the return statement(not pretty but works).

2) Have a second stored procedure call the non-XML version and just return the results using FOR XML.

3) Build the XML in the SELECT statement of the stored procedure.

I''d probably recommend trying #2 first since that would seem to be cleanest approach, but they''re just ideas that you need to flesh out and see which applies best to your problem and your application.

Enjoy.


如何将SP输出转换为XML格式.
此处:类似的讨论 [
How can I convert SP output into XML format.
Here: Similar discussion[^]




您可能还希望了解最佳做法.
http://msdn.microsoft.com/en-us/library/ms187508%28v = sql.90%29.aspx [ ^ ]

祝你好运
Hi,

You may also like to have a look at the best practices. http://msdn.microsoft.com/en-us/library/ms187508%28v=sql.90%29.aspx[^]

Good Luck


这篇关于从存储过程输出中获取XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆