Tengo el siguiente en una variable XML @ResultData
SQL Server XML Espacio de nombres Consulta Problema
<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_>
Pero me parece que no puede seleccionar los valores JournalNum de ella debido a la xmlns=...
en el nodo. En .Net puedo hacer algo como "{http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey}KeyData"
para recuperarlo, pero obtengo un error de sintaxis en SQL.
sólo quiero obtener una lista de los nodos de valor, con el fin documento en una tabla temporal y esto no funciona bien ....
SELECT IDENTITY(int,1,1) as 'ID',
c.query('(KeyData/KeyField/Value)[1]') as 'JournalNum'
INTO #tmpBatches
FROM @ResultData.nodes('//EntityKey') t(c)
Pensamientos? Sugerencias? Soluciones?
Muchas gracias !! Finalmente me deshice de estos molestos espacios de nombres en mis consultas xpath. –