查询文本字段中的 xml 存储
我有一个 sql server 2005 表,其中在文本字段中存储有 xml。 我想知道是否有一种简单的方法(使用 TSQL)从 xml 数据中检索 a 值,而无需对文本进行逐行解析?
进行逐行解析是可能的,因为 xml 的量非常小。 但是,如果可能的话,我想找到一种性能更高的方法。
注意:该 xml 是通过 FoxPro CURSORTOXML 函数(在 FoxPro 前端应用程序中)创建的,然后保存到 sql server 表中的文本字段中。 xml 架构作为存储的 xml 的一部分内置。
任何建议,将不胜感激!
I have a sql server 2005 table which has xml store in a text field. I am wondering if there is an easy way (using TSQL) of retrieving the a value from the xml data without doing a line by line parsing of the text?
Doing a line-by-line parsing is a possibility because the amount of xml is pretty small. However, if possible I would like to find a higher performance method.
NOTE: The xml was created by means of a FoxPro CURSORTOXML function (in a FoxPro front-end application), and was then subsequently saved to a text field in a sql server table. The xml schema is built-in as part of the stored xml.
Any suggestions would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以从列中获取 XML 数据并将其转换为 XML 数据类型,然后使用 XQuery 轻松查询 XML 或使用 XPath 从中提取值。
SQL Server 2005 中的 XML 支持
例如
You can fetch the XML data from the column and convert it to the XML datatype, and query the XML easily using XQuery or use XPath to extract values from it.
XML Support In SQL Server 2005
e.g.
是的。 这里有一个示例“将 XML 导入 SQL Server”和另一个“在 SQL Server 中搜索 XML”
否则,请您发布 xml,我们可以提供一些想法...基于以下内容,解决方案略有不同是否读取值、属性、层次结构等
Yes. An example here "Importing XML into SQL Server" and another "Search XML in SQL Server"
Otherwise, please can you post the xml and we can offer some ideas... there are slightly different solutions based on whether reading values, attributes, hierarchy etc
您将需要对两种解决方案进行性能测试(转换为 XML 与逐行解析)。
You will want to do performance testing on both solutions (convert to XML vs. line-by-line parsing).