DECLARE @xml xml; -- Create sample XML document SET @xml = N' Fabio Claudio Ferracchiati Hugo Kornelis Rob Walters Lara Rubbelke Adam Machanic Michael Coles Robin Dewson Jan D. Narkiewicz Robert Rae 159059794X 6 1590599691 3 6 7 1 8 9 1590599837 6 '; -- Perform outer join SELECT @xml.query('for $author in /authors/author where fn:empty($author[@id = /books/book/author]) return { $author } ');