FIX: Declare Cursor With Comments May Cause Error #707

ID: Q149242


The information in this article applies to:

BUG#: 12824 (6.00)

SYMPTOMS

If a server-side cursor is declared with comments in the select statement, it may cause the following error:

Msg 707, Level 20, State 2 System error detected during attempt to free
memory at address 0xddf000. Please consult the SQL Server error log for
more details. The SQL Server is terminating this process.

It is also possible to cause a thread-level AV.


CAUSE

Limited testing has shown that there is a narrow scope under which this problem is encountered:

  1. Cursor must be deallocated and declared twice in one batch. Breaking it into two separate batches avoids the problem.


  2. Cursor must be deallocated first, declared, opened, fetched, then deallocated again, declared, opened, fetched in the batch. On the second execution of the batch, it would fail on the first deallocate cursor statement. If the cursor is being deallocated at the end of batch, it would not cause the problem.


  3. Cursor must be declared as 'for update.' It does not matter whether it is a scroll cursor or not. It does not matter which fetch mode it is using.


  4. The length of comments is critical here, longer comments may not cause the problem.



WORKAROUND

Do not use comments with the 'declare cursor' statement.


STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.0. This problem has been corrected in U.S. Service Pack 3 for Microsoft SQL Server version 6.0. For more information, contact your primary support provider.

Additional query words: sql6


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

Last Reviewed: March 24, 1999