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 2000 Forums
 Transact-SQL (2000)
 cursors

Author  Topic 

anandc
Starting Member

20 Posts

Posted - 2005-09-06 : 04:08:29
Many a times i have read that we should minimize the use of cursors while writing SP. But in case I need to do some bulk processing of records, then cursors provide a good way to loop thru each record and process them. What are the better alternatives? And on what factors should we decide whether to use cursors or any other technique? I would appreciate if someone could give a detailed explanation of why other techniques can be better as compared to cursors.

Thanks


- Anand

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-06 : 06:18:53
well that's because sql server's engine is optimized for set based processing.
i personally don't have anything against cursors as long as they're not used in production.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-06 : 06:26:16
In most cases cursors can be replaced by Set Based Approach

>>But in case I need to do some bulk processing of records, then cursors provide a good way to loop thru each record and process them

Can you give an example for this?
There may be alternative to Cursor

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -