FIX: Cursor w/ Union May Cause Errors if Not First in Batch

ID: Q138746


The information in this article applies to:

BUG# NT: 11237 (6.00)

SYMPTOMS

If a cursor is opened that contains a union between two queries, you may receive errors such as:

DB-Library: Possible network error: Bad token from SQL Server:
Datastream processing out of sync.
Net-Library error 0:
DB-Library: Possible network error: Bad token from SQL Server:
Datastream processing out of sync. Connection broken.
<above is repeated many times>
Net-Library error 6: ConnectionClose (CloseHandle()).
Msg 533, Level 20, State 4
Can't find a range table entry for range 5.
DB-Library Process Dead - Connection Broken

And in some cases, the following message may also occur:
Msg 16942, Level 16, State 2
Asyncronous keyset generation failed, the cursor has been deallocated


WORKAROUND

This generally occurs when there are other Transact-SQL statements preceding the declaration of the cursor. Moving the cursor to the beginning of the batch may prevent the errors from occurring.


STATUS

Microsoft has confirmed this to be a problem in SQL Server for Windows NT version 6.0. This problem was corrected in Service Pack 2 for SQL Server version 6.0. For more information, contact your primary support provider.


MORE INFORMATION

Changing the UNION to a UNION ALL can cause the problem seemingly to disappear. However, in some cases, the batch runs without any error in the errorlog or to the client, but the connection is broken and the dbproc is dead.

Additional query words: sql6 cursor union dropped


Keywords          : kbprg SSrvProg kbbug6.00 kbfix6.00.sp2 
Version           : 6.0
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: April 20, 1999