declare @xml xml,
declare @num int
set @num = 1
set @xml = '
<row>
<Id>1</Id>
<name>reza</name>
</row>
<row>
<Id>2</Id>
<name>Masoud</name>
</row>
'
如何选择 ID = @num ??
declare @xml xml,
declare @num int
set @num = 1
set @xml = '
<row>
<Id>1</Id>
<name>reza</name>
</row>
<row>
<Id>2</Id>
<name>Masoud</name>
</row>
'
如何选择 ID = @num ??
尝试这个:
这会将整个
<row>
XML 元素作为 XML返回使用XPath 过滤器:
将显示:
<row><Id>1</Id><name>reza</name></row>
。'/row[Id/text()="1"]'
也适用于您的示例,'/row[Id="1"]'
甚至'/row[Id=1]'
.