BUG: Dynamic Cursor Inside a Stored Procedure Using ISNULL() or Date Function May Cause AV

ID: Q249628


The information in this article applies to:
  • Microsoft SQL Server version 6.5

BUG #: 17695 (SQLBUG_65)

SYMPTOMS

If a dynamic SELECT cursor is created using the ISNULL() function or a date function, it results in an access violation (AV) when executed. For the access violation to occur, the following conditions must be met:

  • Cursor must be used inside a stored procedure.


  • A Clustered index must exist on the field that is involved with the function.


  • The returned column is used in an ORDER BY clause. For example:


  • 
    declare c1 cursor
    	for
    	select Field1, ISNULL(Field2, 123456) As FieldX
    	from tblTest
    	order by FieldX 
The problem occurs on all builds of SQL Server 6.5, from release to Service Pack 5a. It does not occur in SQL Server 7.0.


WORKAROUND

Declaring the cursor as INSENSITIVE prevents the access violation from occurring.


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5.

Additional query words:

Keywords : kbSQLServ650
Version : winnt:6.5
Platform : winnt
Issue type : kbbug


Last Reviewed: January 17, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.