declare @xml_doc xml;
declare @xml_doc_handle int;
SET @xml_doc = '
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.tranzaxis.com/tran.wsdl" xmlns:tran="http://schemas.tranzaxis.com/tran.xsd" xmlns:tran1="http://schemas.tranzaxis.com/tran-common.xsd">
<SOAP-ENV:Body>
<Tran>
<tran:Response Id="230425417132544925" OperDay="2022-01-01T00:00:00.000" Result="Approved" ApprovalCode="H8PCL2" Version="3.2.31.10.13">
<tran:CustInfo Kind="Transactions">
<tran1:Item>
<tran1:Attribute Kind="TranTermOwnerRid">
<tran1:StrVal>Commerce Bank</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranId">
<tran1:IntVal>230425416398244922</tran1:IntVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranRegTime">
<tran1:DateTimeVal>2023-04-25T16:33:59.000</tran1:DateTimeVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranKind">
<tran1:StrVal>Payment</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranKindTitle">
<tran1:StrVal>Платеж</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermType">
<tran1:StrVal>Pos</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermOwnerTitle">
<tran1:StrVal>OJSC Commerce Bank of Tajikistan</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermOwnerStreetAddress"/>
<tran1:Attribute Kind="TranContractAmt">
<tran1:NumVal>-1</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranContractDebitHoldAmt">
<tran1:NumVal>0</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranContractCreditHoldAmt">
<tran1:NumVal>0</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranContractCcyAc">
<tran1:StrVal>TJS</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermType">
<tran1:StrVal>Pos</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranPayeeType">
<tran1:StrVal>Vendor</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranCustAmt">
<tran1:NumVal>1</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranCustCcyAc">
<tran1:StrVal>TJS</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranResult">
<tran1:StrVal>Approved</tran1:StrVal>
</tran1:Attribute>
</tran1:Item>
<tran1:Item>
<tran1:Attribute Kind="TranTermOwnerRid">
<tran1:StrVal>Spitamen Bank</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranId">
<tran1:IntVal>220915303177340419</tran1:IntVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranRegTime">
<tran1:DateTimeVal>2022-09-15T13:25:17.000</tran1:DateTimeVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranKind">
<tran1:StrVal>Cash</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranKindTitle">
<tran1:StrVal>Выдача наличных</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermType">
<tran1:StrVal>Pos</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermOwnerTitle">
<tran1:StrVal>000 GO Spitamen Bank</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermOwnerStreetAddress">
<tran1:StrVal>Street 10</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranContractAmt">
<tran1:NumVal>-5</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranContractDebitHoldAmt">
<tran1:NumVal>0</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranContractCreditHoldAmt">
<tran1:NumVal>0</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranContractCcyAc">
<tran1:StrVal>TJS</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranTermType">
<tran1:StrVal>Pos</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranPayeeType"/>
<tran1:Attribute Kind="TranCustAmt">
<tran1:NumVal>5.00</tran1:NumVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranCustCcyAc">
<tran1:StrVal>TJS</tran1:StrVal>
</tran1:Attribute>
<tran1:Attribute Kind="TranResult">
<tran1:StrVal>Approved</tran1:StrVal>
</tran1:Attribute>
</tran1:Item>
</tran:CustInfo>
<tran:Auth/>
</tran:Response>
</Tran>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
';
select [Attribute_King], [StrVal] from (
select T.col.value('@Kind','varchar(30)') as Attribute_King,
T.col.value('.','varchar(30)') as StrVal
from @xml_doc.nodes('//*:Attribute') as T(col)
) as p
UNPIVOT (
T.col.value('@Kind','varchar(30)') as Attribute_King for Attribute_King in([StrVal])
) as piv
select * from (
select T.col.value('@Kind','varchar(30)') as Attribute_King,
T.col.value('.','varchar(30)') as StrVal
from @xml_doc.nodes('//*:Attribute') as T(col)
) as p
PIVOT (
MAX(Attribute_King) for [StrVal] in([230425416398244922], [Payment])
) as piv