are you really on sql server 2000? (I wish I'd checked the forum before replying with this).if you were on 2005 you could do this:SET DATEFORMAT dmyDECLARE @dump TABLE ( [row_ID] VARCHAR(255) , [Par_Row_ID] VARCHAR(255) , [StartDate] DATETIME , [EndDate] DATETIME , [Status] VARCHAR(255) , [PrevRow_ID] VARCHAR(255) )INSERT @dump SELECT '1-7GYPPT', '1-7GYPPQ', '27/01/2010', '27/01/2010', 'New Claim', NULLUNION SELECT '1-7GYPQ0', '1-7GYPPQ', '27/01/2010', '17/02/2010', 'Application Form Sent', NULLUNION SELECT '1-7HD9CC', '1-7GYPPQ', '17/02/2010', '19/02/2010', 'Application Form being checked', NULLUNION SELECT '1-7HDHEL', '1-7GYPPQ', '19/02/2010', '04/03/2010', 'Processing', NULLUNION SELECT '1-7HMQEJ', '1-7GYPPQ', '04/03/2010', '05/03/2010', 'Assistant Manager Review', NULLUNION SELECT '1-7HMX0J', '1-7GYPPQ', '05/03/2010', '08/03/2010', 'Payment Authorised', NULLUNION SELECT '1-7HNQCE', '1-7GYPPQ', '08/03/2010', NULL, 'Completed', NULLUNION SELECT '1-C4L5-425', '1-C45O-487', '23/12/2008', '30/04/2009', 'New Claim', NULLUNION SELECT '1-5DCNL1', '1-C45O-487', '30/04/2009', '22/05/2009', 'Processing', NULLUNION SELECT '1-5PAFX9', '1-C45O-487', '22/05/2009', '05/03/2010', 'Eligible - awaiting maturity', NULLUNION SELECT '1-7HKN81', '1-C45O-487', '05/03/2010', '08/03/2010', 'Offer Accepted', NULLUNION SELECT '1-7HOCW6', '1-C45O-487', '08/03/2010', '08/03/2010', 'Payment Authorised', NULLUNION SELECT '1-7HOCWC', '1-C45O-487', '08/03/2010', '08/03/2010', 'Completed', NULLUNION SELECT '1-7HOK1H', '1-C45O-487', '08/03/2010', NULL, 'Completed', NULLSELECT d.[row_ID] , d.[Par_Row_ID] , d.[StartDate] , d.[EndDate] , d.[Status] , dPrev.[Prev_row_Id]FROM @dump d OUTER APPLY ( SELECT TOP 1 [row_Id] AS [Prev_Row_Id] FROM @dump d2 WHERE d2.[Par_Row_ID] = d.[par_Row_id] AND d2.[endDate] <= d.[startDate] AND d2.[row_Id] <> d.[row_Id] ORDER BY d2.[endDate] DESC ) dPrevORDER BY d.[Par_Row_ID] , d.[startDate] , d.[endDate]
Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION