The mandatory warning now, XQuery like this can be somewhat processor intensive. I wouldn’t suggest running this on a production system unless you were to put more filters in place to trim the data down a bit.

What errors are you getting? Oh, and I didn’t mention this but it is looking at one database in particular, which you can see as qp.dbid=13. That’s one issue that you might need to address. Other than that, without the error message, I don’t know what to tell you.