Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 cursors

Author  Topic 

nextaxtion
Yak Posting Veteran

54 Posts

Posted - 2011-01-06 : 00:56:23
hi, what is global cursor and local cursor ,how can we change global cursors to local cursors


prithvi nath pandey

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-01-06 : 03:15:08
FROM BOL (http://msdn.microsoft.com/en-us/library/ms180169.aspx):
quote:
GLOBAL
Specifies that the scope of the cursor is global to the connection. The cursor name can be referenced in any stored procedure or batch executed by the connection. The cursor is only implicitly deallocated at disconnect.

Note
If neither GLOBAL or LOCAL is specified, the default is controlled by the setting of the default to local cursor database option. In SQL Server version 7.0, this option defaults to FALSE to match earlier versions of SQL Server, in which all cursors were global. The default of this option may change in future versions of SQL Server. For more information, see Setting Database Options.


DECLARE GLOBAL CURSOR cur AS ...

On a side note: cursors are the devil!!

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

nextaxtion
Yak Posting Veteran

54 Posts

Posted - 2011-01-06 : 03:37:56
i hava a global cursor but i don't want to change the code but want to behave like local then...

prithvi nath pandey
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-01-06 : 03:50:21
"I have a doughnut but I would reeeally like it to be a cupcake without touching it. How can I do that?"

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

nextaxtion
Yak Posting Veteran

54 Posts

Posted - 2011-01-06 : 05:48:04
ok...

prithvi nath pandey
Go to Top of Page

michael.appleton
Posting Yak Master

160 Posts

Posted - 2011-01-06 : 06:00:52
What you're saying nextaxtion, makes absolutely no sense. What kind of method did you have in mind to change the behaviour besides changing the code?
Go to Top of Page

nextaxtion
Yak Posting Veteran

54 Posts

Posted - 2011-01-06 : 07:22:12
quote:
Originally posted by michael.appleton

What you're saying nextaxtion, makes absolutely no sense.



OH,REALLY....

prithvi nath pandey
Go to Top of Page

nextaxtion
Yak Posting Veteran

54 Posts

Posted - 2011-01-06 : 07:27:59
how to get all cursors name that are in database in open or closed state.

prithvi nath pandey
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-01-06 : 10:08:19
http://msdn.microsoft.com/en-us/library/ms186256.aspx

It's probably better you spend a few minutes poking around Books Online under "cursors" than posting a lot of onesie-twosie questions about them. It'll save time.
Go to Top of Page
   

- Advertisement -