BUG: UNION with Local Variables GP Faults Server

Last reviewed: April 28, 1997
Article ID: Q87312

The information in this article applies to:
  • Microsoft SQL Server version 4.2 for OS/2
  • Microsoft SQL Server, versions 4.2, 4.21, and 4.21a
BUG# OS/2: 1435 (4.2)
       NT:  851 (4.2)

SYMPTOMS

If you use a union operator to link two select statements that assign values to local variables, SQL Server for OS/2 will general protection fault (GP fault), and SQL Server for Windows NT will have an access violation. However, in SQL Server for Windows NT, only the client connection that runs the query is terminated. The rest of the clients are not affected.

For example, the following query GP faults SQL Server:

   declare @v int
   select @v=1
   UNION
   select @v=1
   go

It is unlikely that you would build such a query, because it assigns multiple values to a single local variable.

CAUSE

SQL Server incorrectly handles the UNION operation if you use the UNION operator to assign multiple values to a local variable.

WORKAROUND

Do not use the UNION operator with local variables. If you are trying to assign different values to a local variable depending on variable conditions, use IF statements instead.

STATUS

Microsoft has confirmed this to be a problem in SQL Server version 4.2 and Microsoft SQL Server versions 4.2, 4.21, and 4.21a. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: Transact-SQL language_exec Windows NT
Keywords : kbbug4.20 kbprg SSrvServer SSrvWinNT
Version : 4.2 | 4.2 4.21 4.21a
Platform : OS/2 WINDOWS


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: April 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.