The topic describes the DF112 T-SQL code analysis rule.
EXECUTION RULES
ORDER BY is used in a view or a single statement (inline) table-valued function.
It is not recommended to use ORDER BY to sort the result set in a view or inline table-valued function, as it does not serve any meaningful purpose.
Views and table-valued functions are typically used for data presentation rather than data storage. In many cases, the order in which data is presented does not affect its underlying meaning or integrity. Therefore, applying ORDER BY in these constructs may not provide significant benefits.
CREATE OR ALTER VIEW dbo.DemoView
AS
SELECT TOP 100 PERCENT
*
FROM master.dbo.spt_values sv
ORDER BY sv.number
GO
SELECT
*
FROM dbo.DemoView dv
CREATE OR ALTER VIEW dbo.DemoView
AS
SELECT TOP 100 PERCENT
*
FROM master.dbo.spt_values sv
ORDER BY sv.number
GO
SELECT
*
FROM dbo.DemoView dv
SELECT TOP 100 PERCENT
*
FROM master.dbo.spt_values sv
ORDER BY sv.number