日期:2014-05-18 浏览次数:20436 次
DECLARE @x XML SET @x='<title lang="en">Everyday Italian</title><title lang="en">XQuery Kick Start</title>' SELECT T.c.value('(.)[1]','VARCHAR(50)') AS en from @x.nodes('title') T(c) /* en -------------------------------------------------- Everyday Italian XQuery Kick Start (2 行受影响) */
------解决方案--------------------
DECLARE @x XML='<title lang="en">Everyday Italian</title><title lang="en">XQuery Kick Start</title>' SELECT @x.query('/title/text()[1]') /* Everyday ItalianXQuery Kick Start */ SELECT t.c.value('.[1]','varchar(50)') FROM @x.nodes('title')T(c) /* Everyday Italian XQuery Kick Start */
------解决方案--------------------
DECLARE @x XML SET @x='<title lang="en">Everyday Italian</title><title2 lang="en">XQuery Kick Start</title2>' SELECT T.c.value('.[1]','VARCHAR(50)') AS en from @x.nodes('*[@lang="en"]') T(c)