Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID Start_dt End_dt
- A 1/1/2010 12/31/2010
- A 1/1/2011 12/31/2011
- A 6/1/2012 12/31/2012
- A 1/1/2014 12/31/2014
- A 1/1/2016 10/31/2016
- A 1/1/2018 12/31/2018
- B 1/1/2016 2/29/2016
- B 3/1/2016 10/31/2016
- B 1/1/2017 7/31/2017
- B 1/1/2019 12/31/9999
- C 1/1/2017 12/31/2017
- C 1/1/2017 12/31/2018
- C 1/1/2019 12/31/9999
- ID Start_dt End_dt
- A 1/1/2010 12/31/2012
- A 1/1/2014 12/31/2014
- A 1/1/2016 10/31/2016
- A 1/1/2018 12/31/2018
- B 1/1/2016 7/31/2017
- B 1/1/2019 12/31/2019
- C 1/1/2017 12/31/9999
- if OBJECT_ID ('tempdb..#test1') is not null
- drop table #test1
- CREATE TABLE #test1 (
- ID varchar(10),
- Start_dt datetime,
- End_dt datetime
- );
- INSERT INTO #test1 VALUES ('A', '1/1/2010', '12/31/2010')
- ,('A', '1/1/2011', '12/31/2011')
- ,('A', '6/1/2012', '12/31/2012')
- ,('A', '1/1/2014', '12/31/2014')
- ,('A', '1/1/2016', '10/31/2016')
- ,('A', '1/1/2018', '12/31/2018')
- ,('B', '1/1/2016', '2/29/2016')
- ,('B', '3/1/2016', '10/31/2016')
- ,('B', '1/1/2017', '7/31/2017')
- ,('B', '1/1/2019', '12/31/9999')
- ,('C', '1/1/2017', '12/31/2017')
- ,('C', '1/1/2017', '12/31/2018')
- ,('C', '1/1/2019', '12/31/2999')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement