I need to come up with a purge routine to keep only the two most recent records for each set of key fields. For instance in this table:
CREATE TABLE [dbo].[Profile_Actuals](
[EffectiveDate] [datetime] NULL,
[Company] [varchar](10) NULL,
[Profile] [varchar](4) NULL,
[Value] [real] NULL
)
GO
For every company and profile combination I need to delete everything except the two most recent (by the EffectiveDate field). Some of them may only have 1, but cannot have more than two.