BUG: UNION with Local Variables GP Faults Server

ID: Q87312


The information in this article applies to:


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          : kbprg kbbug4.20 SSrvServer SSrvWinNT 
Version           : 4.2 | 4.2 4.21 4.21a
Platform          : OS/2 WINDOWS 
Issue type        : 

Last Reviewed: March 16, 1999