Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server

Always close your cursor

5.00/5 (2 votes)
18 Oct 2011CPOL 5.8K  
You also might want to look into the LOCAL keyword.This limits the scope of the cursor to the context in which it is created.DECLARE IdCursor CURSOR LOCAL FOR SELECT Id FROM MyTableThis is beneficial for many reasons.
You also might want to look into the "LOCAL" keyword.
This limits the scope of the cursor to the context in which it is created.

SQL
DECLARE IdCursor CURSOR LOCAL FOR SELECT Id FROM MyTable


This is beneficial for many reasons.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)