BUG: Selecting All Columns from a View Containing an ORDER BY Statement May Result in an Access Violation (279407)



The information in this article applies to:

  • Microsoft SQL Server 7.0

This article was previously published under Q279407
BUG #: 100875 (SQLBUG_70)

SYMPTOMS

IMPORTANT: ORDER BY clauses are not allowed in CREATE VIEW statements in SQL Server 7.0. For more information, see the CREATE VIEW topic in SQL Server Books Online. One of the problems is that SQL Server 7.0 may not return a syntax error when you attempt to create a view with an ORDER BY clause.

If you attempt to select all columns from a view that contains an ORDER BY clause, knowing that this is not supported, and the select list in the view declaration does not contain the column used in the ORDER BY clause, you may receive the following Access Violation (AV) error message:
ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 7 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

WORKAROUND

Move the ORDER BY clause to the SELECT statement that is used to select from the view.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0.

MORE INFORMATION

This functionality works, and is supported, in SQL Server 2000.

Modification Type:MajorLast Reviewed:9/4/2002
Keywords:kbbug KB279407