Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Loop through a result set
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01116848
Message ID:
01116882
Vues:
20
I am giving you the solution stars even if you answered after Kurt (you provided a more complete answer, even though I solved my problem by using the example in BOL as sugested by Kurt).

The result set would never ever be more than 20 and very seldom more than 5. It is really difficult to explain this problem because it is a really odd problem (I need a bottle of Guiness every time I think about it for an extended period of time).

I am mainly coding for SQL2005 but I have up until now (in this project) maintained the possibility for backwards compatability to SQL2000. I guess I would like to stay that way, unless ofcourse it is a really sweeeet feature in SQL2005 that I could utalize.


Hey, Einar,

Thanks for the love. ;)

If it's that few a number, then a cursor is OK. Using the READ_ONLY and FORWARD_ONLY keywords reduces the overhead of cursors (assuming you don't need to modify them, and that you'll only move forwards in them)

In some/many instances, you can avoid cursors by using derived tables or correlated subqueries. And in SQL2005 there are new capabilities for recursive queries. But a cursor should work fine if it's that small.

Kevin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform