Domanda

I have this XML file:

<D>
  <RecordChanged TriggeringTable="Table1" />
  <Demographics Patient_x0020_Number="12984" ChartNo="0"/>
  <Appt ApptID="38155" MDID="54" ApptStart="2013-10-23T13:20:00" PatientID="12988"/>
  <Billing BillingID="37713" ApptID="38035" PatientID="12772"/>
</D>

Now, I want to know the name of each element. So, my answer should be:

RecordChanged ,
Demographics  ,
Appt          , 
Billing 

How can I write the query in SQL Server?

TNX.

È stato utile?

Soluzione

select
    T.C.value('local-name(.)', 'nvarchar(max)') as Name
from @xml.nodes('D/*') as T(C)

sql fiddle demo

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top