MS SQL Tutorial

Source: Internet
Author: User
Tags definition sql tutorial
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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.