I'd suggest to use
CTE[
^]. See:
DECLARE @tmp TABLE(Employee_Id int, StartDate datetime, EndDate datetime, [Text] VARCHAR (50))
INSERT INTO @tmp(Employee_Id, StartDate, EndDate, [Text])
VALUES(1, '2019-09-01', '2019-09-03', 'Demo1 Text'),
(2, '2019-09-04', '2019-09-04', 'Demo2 Text'),
(3, '2019-09-05', '2019-09-08', 'Demo3 Text')
;WITH CTE AS
(
SELECT Employee_Id, 1 AS DayNo, StartDate, EndDate, [Text]
FROM @tmp
UNION ALL
SELECT Employee_Id, DayNo + 1 AS DayNo, DATEADD(DD, 1, StartDate) AS StartDate, EndDate, [Text]
FROM CTE
WHERE DATEADD(DD, 1, StartDate)<=EndDate
)
SELECT *
FROM CTE
ORDER BY Employee_Id, DayNo
For further details, please see:
WITH common_table_expression (Transact-SQL) - SQL Server | Microsoft Docs[
^]
Common Table Expressions (Introduction to CTE's) - Essential SQL[
^]
SQL Server CTE Basics - Simple Talk[
^]
SQL Server Common Table Expressions (CTE)[
^]