SQL server field xml filter for a field with namespace

Asked

Viewed 179 times

0

i tried via seq to filter a record that had an xml field, with this 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 consultation was:

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

and returned nothing, someone has idea what is missing?

1 answer

0


I found out what it’s like:

just put *:<nome do elemento>, so filter by any namespace, have to 'name' the namespace, but for my case it was only filter by the same element.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.