XML Datatype Method – Query()
The Query() method is used to query the XML data using XQuery Expression
The Syntax is
query ('XQuery')
The below shows how to display the xml node where jobid is 1
SELECT JobHistory.query('/Job[@JobID=1]') FROM Employee
The below shows how to display the company name node where jobid is 1
SELECT JobHistory.query('/Job[@JobID=1]/CompanyName/text()') FROM Employee
The Syntax is
query ('XQuery')
The below shows how to display the xml node where jobid is 1
SELECT JobHistory.query('/Job[@JobID=1]') FROM Employee
The below shows how to display the company name node where jobid is 1
SELECT JobHistory.query('/Job[@JobID=1]/CompanyName/text()') FROM Employee
Comments