… As a continuation of my occassional slam on T-SQL cursors, I want you to take just a few minutes to read this blog post by the great Paul Randal. It is brief, but includes screen shots from the execution plans that shows more odd T-SQL cursor behavior. Because he used a dynamic optimistic cursor type, he kept getting keylookups in his query plans, despite the fact that he has indexes on the fields in his queries. This is because the cursor is maintaing a worktable in TempDB that it is using lookups against. This is a very good example of why using sets in T-SQL is much preferable than relying on cursors.