Hi,
Here is the example by which we can count that how many times a particular node is coming.
DECLARE @strXml XML = (
'<Parent>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
<Child>6</Child>
<Child>7</Child>
</Parent>'
)
DECLARE @cnt INT
SET @cnt =
(
SELECT
COUNT(*) AS NodeCount
FROM
(SELECT @strXml) AS XmlTable(XmlColumn)
CROSS APPLY
XmlColumn.nodes('/Parent/Child') XmlTableFunction(XmlColumn2)
)
Here is the example by which we can count that how many times a particular node is coming.
DECLARE @strXml XML = (
'<Parent>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
<Child>6</Child>
<Child>7</Child>
</Parent>'
)
DECLARE @cnt INT
SET @cnt =
(
SELECT
COUNT(*) AS NodeCount
FROM
(SELECT @strXml) AS XmlTable(XmlColumn)
CROSS APPLY
XmlColumn.nodes('/Parent/Child') XmlTableFunction(XmlColumn2)
)
No comments:
Post a Comment