devxlogo

Specify the Order By Clause in a View

Specify the Order By Clause in a View

SQL Server does not allow you to include the Order By clause in a view.To do this, consider using the following workaround:

 USE pubsGOCREATE VIEW AuthorsByNameASSELECT TOP 100 PERCENT *FROM authorsORDER BY au_lname, au_fnameGO

The only time that SQL Server supports an ORDER BY clause in a view is when it is used in conjunction with the TOP keyword.

devx-admin

Share the Post: