将PL / SQL转换为SQL - 按语句连接

时间:2012-05-07 02:07:49

标签: sql sql-server-2008

  

可能重复:
  Simulation of CONNECT BY PRIOR of ORACLE in SQL SERVER

- 我需要将下面的PL / SQL转换为SQL

SELECT  DataMapId, REPLACE((QtyType, '#'), '#') AS QtyTypes
            FROM    (
                        SELECT  DataMapId, '<QtyType>' + cast(DataTypeId as nvarchar(200)) + '</QtyType>' AS QtyType,
                                ROW_NUMBER() OVER (PARTITION BY DataMapId ORDER BY DataTypeId) AS rn
                        FROM    tblDataMapChannels
                    )
            WHERE   CONNECT_BY_ISLEAF = 1
            CONNECT BY  rn = PRIOR rn + 1
                AND     DataMapId = PRIOR DataMapId
            START WITH  rn = 1

0 个答案:

没有答案