将Sql Data转换为XML并将其存储在表中 [英] Converting Sql Data to XML and storing the same in Table

查看:70
本文介绍了将Sql Data转换为XML并将其存储在表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我创建的页面显示的细节很少。

但查询需要更多时间来执行页面。

所以我计划将查询数据转换为XML格式并将其存储在表格中。

然后将XML数据转换为页面显示。



通过执行此行,我可以获取XML数据,但如何将其存储在不同的表中。

 选择 DT = Getdate() into  #TEMP 
SELECT * 来自 #TEMP FOR XML AUTO
SELECT * 来自 #TEMP FOR XML RAW





另外kinldy向我解释XML AUTO和XML RAW有什么区别



请建议或指导我就此而言。

解决方案

刷新以下链接,



http://msdn.microsoft.com/en-us/library/ms191268.aspx [ ^ ]


引用:

RAW模式生成一个< row> SELECT语句返回的行集中每行的元素。您可以通过编写嵌套的FOR XML查询来生成XML层次结构。



AUTO模式通过使用基于的启发式方法在生成的XML中生成嵌套方式指定SELECT语句。您几乎无法控制生成的XML的形状。可以编写嵌套的FOR XML查询以生成超出由AUTO模式启发式生成的XML形状的XML层次结构。



更多信息:http://msdn.microsoft.com/en-us/library/ms178107%28v=sql.105%29.aspx [ ^ ]


Dear Friends,

I have create a page display few details.
But the query takes more time to execute the page.
So I have planed to convert the query data to XML format and store it in a table.
Then converting the XML data to display in page.

By executing the this line i can get the XML data but how to store the same in different table.

Select DT=Getdate() into #TEMP
SELECT * from #TEMP FOR XML AUTO
SELECT * from #TEMP FOR XML RAW



Also kinldy explain me what is difference between XML AUTO and XML RAW

Kindly suggest or guide me on this.

解决方案

Refre the below link,

http://msdn.microsoft.com/en-us/library/ms191268.aspx[^]


Quote:

The RAW mode generates a single <row> element per row in the rowset that is returned by the SELECT statement. You can generate XML hierarchy by writing nested FOR XML queries.

The AUTO mode generates nesting in the resulting XML by using heuristics based on the way the SELECT statement is specified. You have minimal control over the shape of the XML generated. The nested FOR XML queries can be written to generate XML hierarchy beyond the XML shape that is generated by AUTO mode heuristics.


More at: http://msdn.microsoft.com/en-us/library/ms178107%28v=sql.105%29.aspx[^]


这篇关于将Sql Data转换为XML并将其存储在表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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