Created
August 3, 2017 14:21
-
-
Save mjswart/eca87368f5c07e54b2c3243986166dfc to your computer and use it in GitHub Desktop.
xml example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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