日期:2014-05-16 浏览次数:20464 次
DECLARE @x xml
DECLARE @y int =0
while @y<1
BEGIN
select @x = value from xmark1_0_4
where name = 't''+right(cast(1000000+@y as nvarchar),5)+'''
SELECT @x.query('/site/people/person[@id=''person0'']')
set @y = @y +1
END
GO
<site>
<people>
<person id="person0">
<name>tom</name>
</person>
</people>
</site>
DROP TABLE #xmark
go
CREATE TABLE #xmark(NAME NVARCHAR(20), [value] XML)
INSERT #xmark ( NAME, value )
SELECT 'test', N'
<site>
<people>
<person id="person0">
<name>tom</name>
</person>
</people>
</site>
' UNION ALL
SELECT 'noboday', N'
<site>
<people>
<person id="person1">
<name>tom</name>
</person>
</people>
</site>
'
--sql:
SELECT name FROM #xmark
WHERE [value].exist('/site/people/person[@id="person0"]') = 1
/*
name
test
*/