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...
Sur cette page du site, vous pouvez voir la vidéo en ligne SQL Server Cursor Types - KEYSET Cursor | SQL Server Tutorial / TSQL Tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur TechBrothersIT 12 avril 2015, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 4,952 fois et il a aimé 22 téléspectateurs. Bon visionnage!