Home Forums SQL Server 2005 T-SQL (SS2K5) Data transfer while dynamic increment of duplicate values. RE: Data transfer while dynamic increment of duplicate values.

  • With nothing to do any testing with, give this a try:

    WITH BaseData(

    Class,

    Date_Entered,

    PMmiles,

    RO,

    RoDate,

    Time_In,

    Ranking

    )AS(

    SELECT --RO,Time_In, Ranking = DENSE_RANK() OVER (PARTITION BY RO,Time_In ORDER BY NEWID() ASC)

    Class,

    Date_Entered,

    PMmiles,

    RO,

    RoDate,

    Time_In,

    Ranking = row_number() over (partition by RO, RoDate, Time_In order by (select null))

    FROM

    DTAGatHERTZ_RO

    )

    INSERT INTO ROs

    SELECT

    Class,

    Date_Entered,

    PMmiles,

    RO,

    RoDate,

    DATEADD(mi,Ranking - 1, Time_In

    from

    BaseData

    where

    RO = '4187';