相关疑难解决方法(0)

SQL Server Xml命名空间查询问题

我在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_>
Run Code Online (Sandbox Code Playgroud)

但是我似乎无法从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)
Run Code Online (Sandbox Code Playgroud)

思考?建议?解决方案?

xml xpath namespaces sql-server-2008

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

namespaces ×1

sql-server-2008 ×1

xml ×1

xpath ×1