Skip to content

Tag: stored-procedures

TSQL-ORDER BY clause in a CTE expression?

Can we use ORDER BY clause in a CTE expression? Error message: Msg 1033, Level 15, State 1, Line 14 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified. Msg 102, Level 15, State 1, Line 25 Incorrec…