clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1130652 fiddles created (16658 in the last week).

CREATE TABLE [TABLE] (name NVARCHAR(8), dateFrom DATETIME, dateTo DATETIME)
 hidden batch(es)


INSERT INTO [TABLE] VALUES ('Product1', '2019-01-17 00:00:00.000', '2019-01-20 00:00:00.000'), ('Product2', '2019-01-18 00:00:00.000', '2019-01-19 00:00:00.000'), ('Product3', '2019-01-29 00:00:00.000', '2019-01-30 00:00:00.000')
3 rows affected
 hidden batch(es)


SELECT * FROM [TABLE]
name dateFrom dateTo
Product1 17/01/2019 00:00:00 20/01/2019 00:00:00
Product2 18/01/2019 00:00:00 19/01/2019 00:00:00
Product3 29/01/2019 00:00:00 30/01/2019 00:00:00
 hidden batch(es)


WITH cte AS ( SELECT name, dateFrom [date], dateTo FROM [TABLE] /* WHERE dateFrom <= dateTo */ UNION ALL SELECT name, DATEADD(day, 1, [date]), dateTo FROM cte WHERE [date] < dateTo ) SELECT name, [date] FROM cte ORDER BY 1,2
name date
Product1 17/01/2019 00:00:00
Product1 18/01/2019 00:00:00
Product1 19/01/2019 00:00:00
Product1 20/01/2019 00:00:00
Product2 18/01/2019 00:00:00
Product2 19/01/2019 00:00:00
Product3 29/01/2019 00:00:00
Product3 30/01/2019 00:00:00
 hidden batch(es)