Tip: Using ORDER BY in a View or Derived Table

T-SQL syntax doesn’t support an ORDER BY clause in a view or a derived table unless you also include the TOP keyword as part of the SELECT statement.

Brian Moran

June 19, 2001

1 Min Read
ITPro Today logo in a gray background | ITPro Today


T-SQL syntax doesn't support an ORDER BY clause in a view or a derived table unless you also include the TOP keyword as part of the SELECT statement. SQL Server 2000's error message hints at this fact by suggesting that the TOP keyword will help, as the example in Figure A shows. But you can circumvent this restriction by including a TOP 100 PERCENT clause, as the example in Listing A shows.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like