Shred XML Data into Columns/Rows

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello,
I have a XML as below. As you may see, the ErrorMessage node has several
"Error" nodes with attributes and data. Now, I want to get those attribute
names as "columns" and the values in "rows".. (Action, Key, MultiRefId,
Batch... are the columns).

Can someone help me to get this using SQL Server XML capaiblities?. Thanks.


******************
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
<soap:Body>
<AddPartitionResponse xmlns="http://xyz.com/WebServices/";>
<AddPartitionResult>
<Success>false</Success>
<NumberOfBatches>1</NumberOfBatches>
<NumberOfEntities>2</NumberOfEntities>
<RecordsAffected>0</RecordsAffected>
<XmlRequestID>169</XmlRequestID>
<ResponseMessage>Request executed but with errors</ResponseMessage>
<ErrorMessage>
<Error Action="AddPartition" Id="2" Key="MCL_12" MultiRefId="id2"
Batch="1/1" Status="Failed"
FaultCodeNamespace="http://schemas.xmlsoap.org/soap/envelope/";
FaultCodeException="Server.generalException">ERR_REC_EXISTSFailed </Error>
<Error Action="AddPartition" Id="1" Key="MCL_11" MultiRefId="id1"
Batch="1/1" Status="Failed"
FaultCodeNamespace="http://schemas.xmlsoap.org/soap/envelope/";
FaultCodeException="Server.generalException">ERR_REC_EXISTSFailed </Error>
</ErrorMessage>
</AddPartitionResult>
</AddPartitionResponse>
</soap:Body>
</soap:Envelope>
******************
.



Relevant Pages

  • Re: Shred XML Data into Columns/Rows
    ... DECLARE @Xml xml; ... <AddPartitionResponse xmlns="http://xyz.com/WebServices/"</a>;> ... the ErrorMessage node has several ...
    (microsoft.public.sqlserver.xml)
  • Re: Shred XML Data into Columns/Rows
    ... Joe Fawcett (MVP - XML) ... the ErrorMessage node has several ... <AddPartitionResponse xmlns="http://xyz.com/WebServices/"</a>;> ...
    (microsoft.public.sqlserver.xml)