Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursors
Message
 
 
To
17/06/2011 10:22:21
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01514874
Message ID:
01514891
Views:
56
>>SQL Server is all about set-based operations. If you can perform your process with set-based, it will be better than using cursors.
>>If there is absolutely no set-based alternative, then I suggest to read Brad Schulz series about cursors
>>
>>The Truth about Cursors - Part 1
>>
>>and other parts.
>
>I'm not sure what you mean by set based operations
>
>Thanks

Say, in VFP you can do row by row processing using this code
select AliasName
SCAN
   replace ... 
ENDSCAN
In SQL Server cursors will be the analogue of the code above.

However, if you can do just one UPDATE command to change all records at once, in SQL Server it will perform much faster, as this is what SQL Server is designed for.

In other words, you need to only use cursors when there is no set-based alternative or in the very rare cases when cursors perform better than set-based solution.

If you do need to use cursors, then please use them correctly (and Brad shows how in his blog posts).
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform