FIX: Outer Join on View with count() GP Faults SQL

Last reviewed: May 5, 1997
Article ID: Q71142

The information in this article applies to:

  - Microsoft SQL Server version 4.2 for OS/2
BUG# OS/2: 1062 (4.2)

SYMPTOMS

Under certain circumstances, executing a query that does an outer join between a table and a view can cause SQL Server to general protection fault (GP fault).

CAUSE

If the view contains a count() function and a GROUP BY clause, and the query references the column in the count() function, the server will GP fault.

The following script is an example of this problem:

   use pubs
   go

   create view pubtype
   as
   select pub_id, quantity=count(title)
   from titles
   group by pub_id
   go

   select T.type, P.quantity
   from titles T, pubtype P
   where T.pub_id *= P.pub_id
     and P.pub_id = '0877'
   go

   < The server will GP fault >

WORKAROUND

Any of the following variations to the view/query can be used to avoid the problem:

  1. Omit "and P.pub_id = '0877' ".

  2. Omit "quantity=count(titles)" from the view.

  3. Omit the "group by pub_id".

  4. Use an equijoin rather than an outer join.

  5. Use "and T.pub_id = '0877' " rather than "and P.pub_id...".

STATUS

Microsoft has confirmed this to be a problem in SQL Server version 4.2 for OS/2. This problem has been corrected in version 4.2a. For more information, please contact your primary support provider.


Additional query words: outer join group by Transact-SQL
Keywords : kbbug4.20 kbbug4.20a kbprg SSrvServer
Version : 4.2
Platform : OS/2


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 5, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.