Skip to content
Advertisement

Use xQuery to extract attribute values that also exist in SQL variable

XML structure:

I have SQL that will extract the values of the attributes titled name:

This returns a column that looks like:

My problem is that the list of potential attribute values is quite large.
Instead of repeating @name = "AAA" in my query for every attribute value I want to check for, I was hoping I could declare it as a variable like:

And then just stick the variable in the sql like:

but this is not working for any combination of parens,commas,etc I use to build the variable.

Advertisement

Answer

You can use contains function. Declare a variable like so:

And in you query instead of @name = "AAA" use:

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