27,579
社区成员
发帖
与我相关
我的任务
分享
create table tb(name xml)
insert into tb
select '<f><e>1</e><e>2</e></f>' union all
select '<f><e>2</e><e>5</e></f>' union all
select '<f><e>4</e><e>5</e></f>'
declare @XuZuoZhe nvarchar(200)
set @XuZuoZhe = N'5'
select * from tb where name.exist('//e[.=sql:variable("@XuZuoZhe")]')=1
/*
name
-----------------------
<f><e>2</e><e>5</e></f>
<f><e>4</e><e>5</e></f>