目前我正在使用此查询获取结果:
Select *
From Staff
Where StaInsurance.exist('/COLInsuranceCompany/DOInsuranceCompany[Name/text()[. = "Apollo Life Assurance"]]') = 1
如何在查询中使用输入参数而不是硬编码字符串,下面不起作用:
declare @IInsurance nvarchar(200)
set @IInsurance = 'Apollo Life Assurance'
Select *
From Staff
Where StaInsurance.exist('(/COLInsuranceCompany/DOInsuranceCompany/Name[id=(sql:variable("@IInsurance"))])[1]') = 1
答案 0 :(得分:1)
declare @IInsurance nvarchar(200)
set @IInsurance = 'Apollo Life Assurance'
Select *
From Staff
Where StaInsurance.exist('/COLInsuranceCompany/DOInsuranceCompany/Name[text() = sql:variable("@IInsurance")]') = 1