我尝试创建有序的#Temp 表:
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 ;
但我得到错误:
消息 1033,级别 15,状态 1,第 82 行
ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效,除非还指定了 TOP 或 FOR XML。
如何创建有序临时表?