• Note that you don't need CTE N6:

    DECLARE @startdate DATE, @enddate DATE

    SET @startdate = '00010101'

    SET @enddate = '99990101';

    with

    N0 as (SELECT 1 as n UNION ALL SELECT 1) -- 2 rows

    ,N1 as (SELECT 1 as n FROM N0 t1, N0 t2) -- 4 rows

    ,N2 as (SELECT 1 as n FROM N1 t1, N1 t2) -- 16 rows

    ,N3 as (SELECT 1 as n FROM N2 t1, N2 t2) -- 256 rows

    ,N4 as (SELECT 1 as n FROM N3 t1, N3 t2) -- 65,536 rows

    ,N5 as (SELECT 1 as n FROM N4 t1, N4 t2) -- 4,294,967,296 rows

    --,N6 as (SELECT 1 as n FROM N5 t1, N5 t2) -- 18,446,744,073,709,551,616 rows!!

    ,nums as (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) as num FROM N5)

    SELECT DATEADD(day,num-1,@startdate) as thedate

    FROM nums

    WHERE num <= DATEDIFF(day, @startdate, @enddate) + 1

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden