sql >> Database >  >> RDS >> Sqlserver

XQuery- en knooppunt-ID's

U kunt een getallentabel gebruiken en position()

 SELECT  N.Number as ID,
         -- Param 1
         TBL.SParam.value('local-name((*)[1])', 'varchar(50)') as Param1Name,
         TBL.SParam.value('(*)[1]', 'varchar(100)') as Param1Value,             
         -- Param2
         TBL.SParam.value('local-name((*)[2])', 'varchar(50)') as Param2Name,
         TBL.SParam.value('(*)[2]', 'varchar(100)') as Param2Value, 

         -- Param3           
         TBL.SParam.value('local-name((*)[3])', 'varchar(50)') as Param3Name,
         TBL.SParam.value('(*)[3]', 'varchar(100)') as Param3Value,

         -- Param 4
         TBL.SParam.value('local-name((*)[4])', 'varchar(50)') as Param4Name,
         TBL.SParam.value('(*)[4]', 'varchar(100)') as Param4Value,

         -- Param 5
         TBL.SParam.value('local-name((*)[5])', 'varchar(50)') as Param5Name,
         TBL.SParam.value('(*)[5]', 'varchar(100)') as Param5Value

 FROM master..spt_values as N
    cross apply @xmldoc.nodes('/NewDataSet/Table1[position()=sql:column("N.Number")]') AS TBL(SParam)
 where N.type = 'P' and
       N.number between 1 and @xmlDoc.value('count(/NewDataSet/Table1)', 'int')


  1. Hoe match je even letters of oneven letters met regexp voor mysql

  2. SQL Hoe te bepalen of datum maand datum 29,30 of 31 bevat

  3. Hoe te groeperen op maand in MySQL

  4. Hoe registreer ik de uitvoeringstijd van het uitvoeren van SQL-instructies die in bestanden zijn opgeslagen?