Tutorials | view
Q: Why is SQL Server not allowed to use an ORDER BY clause in the view definition?
A: SQL Server does not allow the ORDER BY clause to be used in the view definition to comply with the ANSI SQL-92 standard. Because the principle analysis of the standard requires discussion of the underlying structure of the Structured Query Language (SQL) and the mathematical theory on which it is based, we cannot adequately explain it here. However, if you need to specify an ORDER BY clause in the view, you might consider using the following methods:
Use pubs
Go
CREATE VIEW Authorsbyname
As
SELECT Top PERCENT *
From authors
Order BY au_lname, au_fname
Go
The top structure introduced by Microsoft in SQL Server 7.0 is useful when used in conjunction with an ORDER BY clause. SQL Server supports the use of an ORDER BY clause in a view only when used in conjunction with the top keyword.
Note: The top keyword is an extension of SQL Server to the ANSI SQL-92 standard.