SQL server xml field filtered by a field with namespace

0

I tried via seq to filter a record that had an xml field, with that xml below:

    <ns1:Prod xmlns:ns1="uri">  
  <ns1:ProductID>316</ns1:ProductID>  
  <ns1:Name>Blade</ns1:Name>  
</ns1:Prod>  
<ns1:Prod xmlns:ns1="uri">  
  <ns1:ProductID>317</ns1:ProductID>  
  <ns1:Name>LL Crankarm</ns1:Name>  
  <ns1:Color>Black</ns1:Color>  
</ns1:Prod>

and my query was:

    select *
from tabela
where [campo_xml].value('(/Prod//ProductID//node())[1]', 'int') = 316

and did not return anything, does anyone have any idea what's missing?

    
asked by anonymous 10.01.2018 / 19:20

1 answer

0

I found out what it looks like:

Just put *:<nome do elemento> , so it filters through any namespace, it has the namespace 'nickname', but for my case it was just filtering through the same element.

    
11.01.2018 / 12:25