2 set @x='%26lt;book genre="security" publicationdate="2002" ISBN="0-7356-1588-2"%26gt;
3 %26lt;title%26gt;Writing Secure Code%26lt;/title%26gt;
4 %26lt;author%26gt;
5 %26lt;first-name%26gt;Michael%26lt;/first-name%26gt;
6 %26lt;last-name%26gt;Howard%26lt;/last-name%26gt;
7 %26lt;/author%26gt;
8 %26lt;author%26gt;
9 %26lt;first-name%26gt;David%26lt;/first-name%26gt;
10 %26lt;last-name%26gt;LeBlanc%26lt;/last-name%26gt;
11 %26lt;/author%26gt;
12 %26lt;price%26gt;39.99%26lt;/price%26gt;
13%26lt;/book%26gt;'
14
15
16
17SELECT nref.value('first-name[1]', 'nvarchar(50)') FirstName,
18 nref.value('last-name[1]', 'nvarchar(50)') LastName
19FROM @x.nodes('//author') AS R(nref)
20
21
结果为
