• I tried the following (after making a table calles Results):

    SELECT @SQL = String FROM SQL_String

    SET @SQL = 'SELECT ev.Event_Name INTO dbo.Results' + 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

    but that does not work at all. The table has two fields: Event_Name and @SQL.

    I also tried the following:

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

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

    'WHERE ev.event_year = @Year '

    with the same result. Nothing but errors.

    What am I doing wrong?

    Robert