New answers tagged xml
Somewhat simpler than the FLWOR version. select * from myTable where yourXML.exist('(Z/A,z/a)[(b,B)=1]') = 1
You can easily test the performance yourself. Create a regular table that you can test your queries on. create table myTable ( yourXML XML ) Add a couple of rows that will give you a match. INSERT INTO myTable SELECT '<z><a><b>1</b><c>2</c></a></z>' INSERT INTO myTable SELECT ...
Use predicates with name tests like this instead of "simple" node steps: /*[lower-case(local-name(.)) = 'z']/*[lower-case(local-name(.)) = 'a']
You can use a variant of the technique described in Using merge..output to get mapping between source.id and target.id and by Adam Machanic in Dr. OUTPUT or: How I Learned to Stop Worrying and Love the MERGE. You use merge and capture the generated ID with the XML fragment that belongs to that ID in a table variable and then use that table variable when ...
Top 50 recent answers are included