【发布时间】:2015-08-18 00:23:31
【问题描述】:
提前感谢您的帮助!我正在尝试对设置如下的 XML 列编写查询:
<DictionaryOfStringObject>
<Item>
<Key>
<string>Info</string>
</Key>
<Value>
<SerializableDictionaryOfStringObject>
<Item>
<Key>
<string>FirstName</string>
</Key>
<Value>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" xmlns:d7p1="http://www.w3.org/2001/XMLSchema-instance" d7p1:type="q1:string">JON</anyType>
</Value>
</Item>
<Item>
<Key>
<string>MiddleName</string>
</Key>
<Value>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" xmlns:d7p1="http://www.w3.org/2001/XMLSchema-instance" d7p1:type="q1:string" />
</Value>
</Item>
<Item>
<Key>
<string>LastName</string>
</Key>
<Value>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" xmlns:d7p1="http://www.w3.org/2001/XMLSchema-instance" d7p1:type="q1:string">SNOW</anyType>
</Value>
</Item>
<Item>
<Key>
<string>Gender</string>
</Key>
<Value>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" xmlns:d7p1="http://www.w3.org/2001/XMLSchema-instance" d7p1:type="q1:string">Male</anyType>
</Value>
</Item>
我需要为表格中的每一行提取此列中的信息。我不是在寻找特定的人。我需要从表中每一行的列中提取此信息。
我了解为特定人员查询单行,但我如何开发一个 SELECT 语句来为每一行在整个表中提取此信息?
每个人在表中都有一行和一个 XML 列,我需要开发一个查询来针对该表运行,该表将提取每个人的信息。
Row 1 = FirstName1, LastName1, Gender1
Row 2 = FirstName2, LastName2, Gender2
我从来没有为这样的标签写过查询,有人可以帮我为SQL Server 2008和SQL Server 2010开发一个Select语句。
我有一些 XML 经验,但可以使用示例和说明来说明如何实现。
【问题讨论】:
-
在此处查看答案:stackoverflow.com/questions/10344553/…。另一个关于如何在 SQL Server 中使用 XML 的好资源,brokenwire.net/bw/Programming/125/…
-
感谢您的回复,我意识到我现在需要编辑我的问题。那些不直接回答我的问题。我不是在搜索特定的名字组合我想为表格的每一行选择此信息。
-
您的 XML 似乎被切断了。你能把整件事都贴出来吗?
标签: sql sql-server xml database