Count Specific Node in XML using SQL

I'm going to explain an example to find the node from an XML file using SQL Server

declare @xml-var  XML;
set @xml-var [email protected];
select @[email protected]('count(/courses/course)', 'INT')

In the above example,

@Result is an XML file, where we find the nodes.

@xml-var is an XML type variable.

Here XML file look like this...

<?xml version="1.01" encoding="ISO-55-4"?>
 - <course>
       <body>Something here,,,,,,!</body>
 - <course>
       <body>Something here,,,,,,!</body>
 - <course>
       <body>Something here,,,,,,!</body>


Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
Post a Comment Powered by Blogger.
ASK Questions