从存储过程输出中获取XML

编程入门 行业动态 更新时间:2024-10-25 04:16:54
本文介绍了从存储过程输出中获取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[^]

您可能还希望了解最佳做法. msdn.microsoft/en-us/library/ms187508%28v = sql.90%29.aspx [ ^ ] 祝你好运 Hi, You may also like to have a look at the best practices. msdn.microsoft/en-us/library/ms187508%28v=sql.90%29.aspx[^] Good Luck

更多推荐

从存储过程输出中获取XML

本文发布于:2023-10-28 23:18:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538054.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:存储过程   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!