【发布时间】:2010-11-02 20:41:47
【问题描述】:
我在 xml 变量 @ResultData 中有以下内容
<EntityKey_x005B__x005D_>
<EntityKey>
<KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
<KeyField>
<Field>JournalNum</Field>
<Value>LJRN000071</Value>
</KeyField>
</KeyData>
</EntityKey>
<EntityKey>
<KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
<KeyField>
<Field>JournalNum</Field>
<Value>LJRN000072</Value>
</KeyField>
</KeyData>
</EntityKey>
<EntityKey>
<KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
<KeyField>
<Field>JournalNum</Field>
<Value>LJRN000073</Value>
</KeyField>
</KeyData>
</EntityKey>
<EntityKey>
<KeyData xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
<KeyField>
<Field>JournalNum</Field>
<Value>LJRN000074</Value>
</KeyField>
</KeyData>
</EntityKey>
</EntityKey_x005B__x005D_>
但由于节点上的xmlns=...,我似乎无法从中选择 JournalNum 值。在 .Net 中,我可以执行 "{http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey}KeyData" 之类的操作来检索它,但我在 SQL 中遇到语法错误。
我只想按文档顺序将 Value 节点列表放入临时表中,但这也不起作用....
SELECT IDENTITY(int,1,1) as 'ID',
c.query('(KeyData/KeyField/Value)[1]') as 'JournalNum'
INTO #tmpBatches
FROM @ResultData.nodes('//EntityKey') t(c)
想法?建议?解决方案?
【问题讨论】:
标签: xml sql-server-2008 namespaces xpath