Praveen Kumar

Praveen Kumar

  • 284
  • 6.6k
  • 2.3m

How to read repeated node value in SQL Server

Jun 18 2021 8:21 AM

How we can read all OrderId. I am using the following code to read but it is reading only first orderId

Sample Code

DECLARE @InputXMLHandle int
Declare @RequestXml xml = '
<Request>
  <OrderStatus>
    <OrderId>RSIN10095</OrderId>
    <OrderId>RSIN10096</OrderId>
  </OrderStatus>
</Request>
'
EXEC sp_xml_preparedocument @InputXMLHandle OUTPUT, @RequestXml
    
Select *
From OPENXML(@InputXMLHandle,'/Request/OrderStatus')
WITH
(     
    OrderId varchar(50) 'OrderId'
)

 


Answers (1)