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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist