I have some records that have over lapping dates. I need to end date them in such a way to fixover lapping dates. See example and expected results.[code="sql"]declare @overlap table(ID int identity,infoname char(10),code char(10),mods char(30),type varchar(30),effective date ,termination date)insert into @overlapselect 'DUMMY','99205','C','*','01/01/2008','12/31/2100'insert into @overlapselect 'DUMMY','99205','C','*','01/01/2009','12/31/2100'insert into @overlapselect 'DUMMY','99205','C','*','01/01/2010','12/31/2100'insert into @overlapselect 'DUMMY','99206','x','*','01/01/2011','12/31/2100'insert into @overlapselect 'DUMMY','99206','x','*','01/01/2012','12/31/2100'insert into @overlapselect 'DUMMY','99206','x','*','01/01/2013','12/31/2100'SELECT * FROM @OVERLAP[/code][quote]/*------------------------------- expected results-------------------------------1 DUMMY 99205 C * 2008-01-01 2008-12-312 DUMMY 99205 C * 2009-01-01 2009-12-313 DUMMY 99205 C * 2010-01-01 2100-12-31 <-unchanged4 DUMMY 99206 x * 2011-01-01 2011-12-315 DUMMY 99206 x * 2012-01-01 2012-12-316 DUMMY 99206 x * 2013-01-01 2100-12-31 <-unchanged*/[/quote]
↧