Applications can request a cursor type and then execute a Transact-SQL statement that is not supported by server cursors of the type requested. Microsoft® SQL Server™ returns an error that indicates the cursor type has changed.
These are the factors that trigger SQL Server version 7.0 to implicitly convert a cursor from one type to another.
Step |
Conversion triggered by | Forward-only | Fast-forward | Keyset-driven | Dynamic |
Go to step |
---|---|---|---|---|---|---|
1 | Cursor references a view with a TOP clause. | Becomes static. | Becomes static. | Becomes static. | Becomes static. | Done |
2 | Query FROM clause references no tables. | Becomes static. | Becomes static. | Becomes static. | Done | |
3 | Query contains: select list aggregates GROUP BY UNION DISTINCT HAVING |
Becomes static. | Becomes static. | Becomes static. | Done | |
4 | Query references a table with a trigger. | Becomes static. | Becomes static. | Becomes static. | Done | |
5 | Query joins a trigger table to another table. | Becomes static. | Done | |||
6 | READ_ONLY is not specified. | Becomes static. | 8 | |||
7 | ODBC API server cursor references text, ntext, or image columns. | Becomes dynamic. | 8 | |||
8 | Query generates an internal work table, for example the columns of an ORDER BY are not covered by an index. | Becomes keyset. | Becomes keyset. | 10 | ||
9 | Query references remote tables in linked servers. | Becomes keyset. | Becomes keyset. | Becomes keyset. | 10 | |
10 | Query references at least one table without a unique index. | Becomes static. | Done |
SQL Server version 6.5 has this restriction in addition to the restrictions in SQL Server 7.0:
An index column cannot be used to cover the ORDER BY if there are index columns to its left that are not referenced by the ORDER BY. For example, if an index is defined as using MyTable (LastName, FirstName), the index cannot be used to cover a statement using ORDER BY FirstName.
The SQL Server version 6.0 restriction regarding dynamic cursors is more simply defined:
If you are using API server cursors and get a message indicating the cursor type has been changed, you can call the following functions to see the type of cursor SQL Server opened:
dbcursorinfoex | Implicit Cursor Conversions (ODBC) |