Skip to content

Instantly share code, notes, and snippets.

Created Aug 3, 2017
What would you like to do?
xml example
declare @xml xml = N'
<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>
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