Skip to content

Instantly share code, notes, and snippets.

@mjswart
Created Aug 3, 2017
Embed
What would you like to do?
xml example
declare @xml xml = N'
<root>
<blat x="abc1">asdf</blat>
<blat x="abc2">asdf</blat>
<blat x="def">asdf</blat>
<blat x="def">asdf</blat>
<blat y="abc">asdf</blat>
</root>';
select nodes.n.query('.')
from @xml.nodes('//blat[(@x)]') nodes(n)
cross apply (select nodes.n.value('(./@x)[1]', 'nvarchar(100)')) as x(val)
where x.val like 'abc%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment