sql >> Databáze >  >> RDS >> Sqlserver

XQuery a ID uzlů

Můžete použít číselnou tabulku a 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. Proč se mi zobrazuje 'Nedefinovaný offset:0'?

  2. SQL Server 2008 změna zachycení dat vs spouštěče v auditní stopě

  3. Jedinečné omezení na kombinaci dvou sloupců?

  4. S PHP odečtěte množství z tabulky mysql