Read XML into row records

黄舟
Release: 2017-02-28 17:07:47
Original
1566 people have browsed it

Read XML as line record

1 declare @x xml
2 set @x=&#39;<book genre="security" publicationdate="2002" ISBN="0-7356-1588-2">
3   <title>Writing Secure Code</title>
4   <author>
5      <first-name>Michael</first-name>
6      <last-name>Howard</last-name>
7   </author>
8   <author>
9      <first-name>David</first-name>
10      <last-name>LeBlanc</last-name>
11   </author>
12   <PRice>39.99</price>
13</book>&#39;
14
15
16
17SELECT nref.value(&#39;first-name[1]&#39;, &#39;nvarchar(50)&#39;) FirstName,
18       nref.value(&#39;last-name[1]&#39;, &#39;nvarchar(50)&#39;) LastName
19FROM   @x.nodes(&#39;//author&#39;) AS R(nref)
20
21
Copy after login

The result is

Read XML into row records

The above is the content of reading XML as line record, For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!