SQL Server Cursor Operators – Part2

Hi Friends,

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.

CQueryPlan_2

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

CQueryPlan_3

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.

Happy Learning!

Regards,

Kanchan

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook | Follow me on Twitter | Follow me on FaceBook

   

About Kanchan Bhattacharyya

Kanchan is an astute IT professional, a seasoned SQL Database Administrator with 13+ years of industry experience. A calculated risk taker with deep technical knowledge and has gained proficiency in database consulting and solutions across different environments. Kanchan holds MBA degree in IT and an International Executive MBA in Project Management. He is very passionate about SQL Server and holds MCSE (Data Platform), MCSA – SQL 2012, MCITP – SQL 2008 certifications. Currently he is focusing on cloud and latest releases of SQL Server. When not working, Kanchan likes to spend his time reading on new technical developments specifically on SQL Server and other related technologies.

View all posts by Kanchan Bhattacharyya →

Leave a Reply

Your email address will not be published.