Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cursors
Message
 
 
À
17/06/2011 10:22:21
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01514874
Message ID:
01514891
Vues:
57
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform