sql 2005 xml 学习

declare @Xml xml
set @Xml='<book genre="security" publicationdate="020022342345345" ISBN="0-7356-1588-2">
   <title>Writing Secure Code</title>
   <author>
      <first-name>Michael</first-name>
      <last-name b="1">Howard</last-name>
   </author>
   <author>
      <first-name>David</first-name>
      <last-name>LeBlanc</last-name>
   </author>
   <price>39.99</price>
</book>
'
if exists
declare @LastName nvarchar(50)
set @LastName=@Xml.value('(/book)[1]/@publicationdate''bigint')
DECLARE @isbn varchar(20)
SET     @isbn = '0-7356-1588-2'
if(@Xml.exist ('/book[@ISBN = sql:variable("@isbn")]'= 1)
begin
select @LastName
end
posted @ 2006-01-18 21:58  .NetFox  阅读(390)  评论(1)    收藏  举报