When we open Keyset Cursor the membership and order of rows in the cursor is fixed. KeySet Cursor create a temp table in TempDB with uniquely built values from the columns which we use in Select statement.
Here are important points to remember about KEYSET Cursor in SQL Server
If your Select query is using any table without Unique Index, the KEYSET cursor is simply going to be converted to Static Cursor. Make sure all of the tables you are using in Select Query has unique index. This is important as KEYSET Cursor build unique identifiers for the rows by using these unique values.
If we insert the rows in source table/s once the cursor is open. Those Inserts will not be visible in already opened cursor.
If we make update to nonkey values in the base tables, those changes will be visible in cursor.
If you update the Key column value in Base Table/s while the cursor is opened and then try to fetch the value. @@FETCH_STATUS will return you -2. The updated made inside the cursor to Key Column with WHERE CURRENT OF clause will be visible at the end of Cursor.
If you delete the row from Base Table/s while the cursor is open and then try to fetch that row in cursor, @@FETCH_STATUS will return -2.
KEYSET cursors are scrollable.
Blog post link for the video with scripts
http://sqlage.blogspot.com/2015/04/sq...
En esta página del sitio puede ver el video en línea SQL Server Cursor Types - KEYSET Cursor | SQL Server Tutorial / TSQL Tutorial de Duración hora minuto segunda en buena calidad , que subió el usuario TechBrothersIT 12 abril 2015, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 4,952 veces y le gustó 22 a los espectadores. Disfruta viendo!