martes, 26 de enero de 2021

XML to TABLE sql-t; Read XML with SQL

EJEMPLO DE CÓMO LEER UN XML CON APOYO DE SQL SERVER  SQL-T 



XML = 

<Reporte xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <status>OK</status>
  <nombre> Energía Asignada de Importación y Exportación</nombre>
  <proceso>MDA</proceso>
  <sistema>BCA</sistema>
  <area>PÚBLICA</area>
  <Enlace_Int>
    <enlace_int>LA ROSITA - IMPERIAL VALLEY</enlace_int>
    <Valores>
      <Valorv3>
        <fecha>2021/01/26</fecha>
        <hora>1</hora>
        <imp_comer_asig>0</imp_comer_asig>
        <imp_asig_ener_inad>0</imp_asig_ener_inad>
        <imp_asig_conf>0</imp_asig_conf>
        <imp_asig_cil>0</imp_asig_cil>
        <imp_total>0</imp_total>
        <exp_comer_asig>0</exp_comer_asig>
        <exp_asig_ener_inad>0</exp_asig_ener_inad>
        <exp_asig_conf>0</exp_asig_conf>
        <exp_asig_cil>0</exp_asig_cil>
        <exp_total>0</exp_total>
      </Valorv3>
      <Valorv3>
        <fecha>2021/01/26</fecha>
        <hora>2</hora>
        <imp_comer_asig>0</imp_comer_asig>
        <imp_asig_ener_inad>0</imp_asig_ener_inad>
        <imp_asig_conf>0</imp_asig_conf>
        <imp_asig_cil>0</imp_asig_cil>
        <imp_total>0</imp_total>
        <exp_comer_asig>0</exp_comer_asig>
        <exp_asig_ener_inad>0</exp_asig_ener_inad>
        <exp_asig_conf>0</exp_asig_conf>
        <exp_asig_cil>0</exp_asig_cil>
        <exp_total>0</exp_total>
      </Valorv3>

 

@Valor contiene el XML