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

Comments

Popular posts from this blog

“Unable to retrieve the metadata for …” Error while using ASP.NET MVC 3

Building application using ASP.NET MVC and MongoDB

Visual Studio 2013 and .NET 4.5.1