Cursors | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive


Does the usage of Cursors affect performance of the code?
Yes. —
Frank Kalis
Microsoft SQL Server MVP
Use cursors only if you need to do things that you cannot do in set-based queries (SELECT, UPDATE, INSERT, DELETE) with JOINs. If you were schooled in a programming language like VB, perhaps you know only how to run a query against a single table, and are not aware of the complex operations you can do in a single T-SQL statement. No need to compare performance between the two: if you have the choice, then set-based is always quicker (and probably easier to program as well), and if you can only do it in a cursor then you’ll just have to accept the performance as it is.
hii adriaan,
can u provide any link or sample showing set based queries, really it will be interesting to work on performance tuning. Mat
Why not show us what your cursor is doing? Mind you, you might have a situation that can only be addressed with a cursor.

1 In most of the cases cursors should be avoided 2
Cursor seems faster if you generate running totals Madhivanan Failing to plan is Planning to fail