读取XML为行记录
类别: HTML、CSS教程
declare @x xml
set @x=\'<book genre="security" publicationdate="2002" ISBN="0-7356-1588-2">
<title>Writing Secure Code</title>
<author>
<first-name>Michael</first-name>
<last-name>Howard</last-name>
</author>
<author>
<first-name>David</first-name>
<last-name>LeBlanc</last-name>
</author>
<price>39.99</price>
</book>\'
SELECT nref.value(\'first-name[1]\', \'nvarchar(50)\') FirstName,
nref.value(\'last-name[1]\', \'nvarchar(50)\') LastName
FROM @x.nodes(\'//author\') AS R(nref)
set @x=\'<book genre="security" publicationdate="2002" ISBN="0-7356-1588-2">
<title>Writing Secure Code</title>
<author>
<first-name>Michael</first-name>
<last-name>Howard</last-name>
</author>
<author>
<first-name>David</first-name>
<last-name>LeBlanc</last-name>
</author>
<price>39.99</price>
</book>\'
SELECT nref.value(\'first-name[1]\', \'nvarchar(50)\') FirstName,
nref.value(\'last-name[1]\', \'nvarchar(50)\') LastName
FROM @x.nodes(\'//author\') AS R(nref)
-= 资 源 教 程 =-
文 章 搜 索