读取XML为行记录
下面是个简单易学的读取XML为行记录教程,图老师小编详细图解介绍包你轻松学会,喜欢的朋友赶紧get起来吧!
2 set @x='book genre="security" publicationdate="2002" ISBN="0-7356-1588-2"
3 titleWriting Secure Code/title
4 author
5 first-nameMichael/first-name
6 last-nameHoward/last-name
7 /author
8 author
9 first-nameDavid/first-name
10 last-nameLeBlanc/last-name
11 /author
12 price39.99/price
13/book'
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
结果为