I try to create ordered #Temp table:
WITH Ordered AS (
SELECT ROW_NUMBER() OVER (ORDER BY [Quality] DESC) AS RowNumber, ImageID, Quality, Border, IsBest
FROM [CatalogImages].[dbo].[Images] ORDER BY Quality)
SELECT *
INTO #Temp
FROM Ordered ;
SELECT * FROM #Temp ;
but I get error:
Msg 1033, Level 15, State 1, Line 82
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
How to create ordered temp table?