Вопрос

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.

Это было полезно?

Решение

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

sql fiddle demo

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top