• This is mostly a dynamic cross-tab. It's not that hard when you understand them, but you need to be really careful on what you're doing.

    Please, test the code and be sure to understand it. You might need to change somethings but this can give you an idea.

    By the way, your data had some dates wrong.

    DECLARE @Edition_Yearint

    DECLARE @SQLnvarchar( 4000) = '';

    SET @Edition_Year = '2012';

    WITH Edition_Calendar AS(

    SELECT DATEADD( DAY, t.N -1, ed.Edition_Start) dates

    FROM #Editions ed

    CROSS

    JOIN dbo.Tally t

    WHERE ed.Edition_Year = @Edition_Year

    AND ed.Edition_Finish >= DATEADD( DAY, t.N -1, ed.Edition_Start)),

    SQL_String( String) AS(

    SELECT ',CASE WHEN ''' + CONVERT( char(8), dates, 112) + ''' BETWEEN ev.Event_Start AND ev.Event_Finish ' + CHAR(10) +

    'THEN ''X'' ELSE '''' END AS ''' + CONVERT( char(5), dates, 5) + '''' + CHAR(10)

    FROM Edition_Calendar

    FOR XML PATH(''))

    SELECT @SQL = String FROM SQL_String

    SET @SQL = 'SELECT ev.Event_Name ' + CHAR(10) + @SQL +

    'FROM #Events ev ' + CHAR(10) +

    'WHERE ev.event_year = @Year '

    --PRINT @SQL

    EXEC sp_executesql @SQL, N'@Year int', @Year = @Edition_Year

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2