我有一個xml變量@ResultData
SQL Server的XML命名空間查詢問題
<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中出現語法錯誤。
我只是想獲得超值的節點列表,文檔順序到一個臨時表,這也不管用....
SELECT IDENTITY(int,1,1) as 'ID',
c.query('(KeyData/KeyField/Value)[1]') as 'JournalNum'
INTO #tmpBatches
FROM @ResultData.nodes('//EntityKey') t(c)
的思考?建議?解決方案?
非常感謝你!我終於在我的xpath查詢中擺脫了這些煩人的命名空間。 – 2013-09-23 14:44:45