Yesterday we have covered first part of the execution plan used in our example and in case you missed that, please click on SQL Server Cursor Operators – Part1 and read before today’s post.
Today, we are going to explore execution plan generated for following SQL statements.
--Click on Display Estimated Execution Plan icon OPEN TerritoryName FETCH NEXT FROM TerritoryName
Note: Please click on ‘Display Estimated Execution Plan’ icon.
Operators in above execution plan in general referred as Cursor Catchcall. For the query used in our example, we can see catchcall operators for OPEN CURSOR and FETCH CURSOR operations.
Moving ahead, FETCH CURSOR command shows a language element and for the WHILE LOOP execution plan shows a conditional operator.
--Click on Display Estimated Execution Plan icon WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM TerritoryName END CLOSE TerritoryName DEALLOCATE TerritoryName
And finally, Close and Deallocate removes the cursor from tempdb and they are represented as cursor catchcall operators as seen above.
Tomorrow we are going to explore more and delve into the plan, stay tuned.