SQL Server R2 2008 needs the AS
clause as follows:
SELECT *
INTO #temp
FROM (
SELECT col1, col2
FROM table1
) AS x
The query failed without the AS x
at the end.
It's also needed when using SS2016, had to add as t
to the end.
Select * into #result from (SELECT * FROM #temp where [id] = @id) as t //<-- as t