Skip to content
Advertisement

SQL Server transform xml and parse single values but not with build-in functions

I am trying to parse and transform XML values in SQL Server 2016. I can not use the the sp_xml_preparedocument or sp_xml_removedocument built-in procedures because I want to have it in a table value function.

I would like to select these 4 values:

  • testXML…821327282
  • Test value
  • Test attribute
  • Test property

XML template value:

My T-SQL try > code:

Advertisement

Answer

Try this:

Not sure what you mean by selecting the testXML...821327282 value – that’s a XML element / node – not a value…..

Update: if you need to get the “name” of the root node element – you can use this – BE AWARE that using the //myvalue approach is very bad for query performance – especially on larger XML documents! You’ve been warned!

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement