BUG: Access Violation Occurs on DECLARE CURSOR with Correlated Subquery and KEYSET or DYNAMIC Cursor Type (282831)
The information in this article applies to:
This article was previously published under Q282831
BUG #: 55675 (SQLBUG_70)
SYMPTOMS
An Access Violation (AV) may occur on an sp_cursoropen or DECLARE CURSOR statement if the following conditions are met:
- A SELECT statement involves a correlated subquery.
- The correlation is through either an IN or an OR clause, with at least two different columns to compare to on the right side.
- A non-clustered primary key is on both correlated tables.
- The subquery table does not have any additional clustered indexes.
- The cursor type is KEYSET or DYNAMIC. This problem does not occur with INSENSITIVE, STATIC, or FAST_FORWARD cursors.
The SELECT statement works fine outside the cursor.
WORKAROUND
To work around this behavior:
- Replace PRIMARY KEY NONCLUSTERED with PRIMARY KEY CLUSTERED.
-or-
- Add a clustered index to the correlated subquery table.
-or-
- Change the cursor type to STATIC, FAST_FORWARD or INSENSITIVE.
-or-
- Rewrite the SELECT statement to avoid the correlated subquery.
STATUS
Microsoft has confirmed this to be a problem in SQL Server 7.0.
Modification Type: | Major | Last Reviewed: | 10/16/2002 |
---|
Keywords: | kbBug kbDSupport KB282831 |
---|
|