0

Currently i am using this query to get results :

Select *
From Staff 
Where StaInsurance.exist('/COLInsuranceCompany/DOInsuranceCompany[Name/text()[. = "Apollo Life Assurance"]]') = 1  

How can i use a Input Parameter instead of hardcoded string in the query, below did not work :

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 Answer 1

1
declare @IInsurance nvarchar(200)
set @IInsurance = 'Apollo Life Assurance'

Select *
From Staff 
Where StaInsurance.exist('/COLInsuranceCompany/DOInsuranceCompany/Name[text() = sql:variable("@IInsurance")]') = 1 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks it worked after removing the '/' from the last
@user2561997 yes, a small mistake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.