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 (3 votes)
18 Oct 2011CPOL 10.9K  
To see the default value of the cursor scope:select * from sys.databases(if value of is_local_cursor_default is 0 then scope id global, otherwise it is local).The scope is GLOBAL by default (for compatibility reasons).To change default scope use following:ALTER DATABASE...
To see the default value of the cursor scope:

SQL
select * from sys.databases

(if value of "is_local_cursor_default" is 0 then scope id global, otherwise it is local).
The scope is GLOBAL by default (for compatibility reasons).
To change default scope use following:
SQL
ALTER DATABASE [YourDatabase] SET CURSOR_DEFAULT LOCAL; 

License

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