Just an observation, but I believe most XQuery commands need string literals for their parameters, not strings (so no variables). So if you know the schema structure and are querying against that, you're okay, but if you're writing code to explore, it gets harder. You're stuck using dynamic SQL, and to my knowledge, there's no ChildNodes equivalent. If someone knows otherwise, I'm very interested.