Possible Duplicate:
What is wrong with Cursors ?
Why we say cursor will affect the performance. Even we use some other looping instead of cursors it works similarly right? Please advise
Possible Duplicate:
What is wrong with Cursors ?
Why we say cursor will affect the performance. Even we use some other looping instead of cursors it works similarly right? Please advise
If your SQL is designed to work RBAR (Row-by-agonizing-row) then a Loop or Cursor will take a long time.
SQL is best with set data, work with sets instead of rows and your performance will generally increase.
If you rephrase your question or post some example SQL, we might be able to help more!
Cursors can affect performance if you use them to keep locks on data. Fast forward cursors are OK. However, T-SQL cursors can easily disguise bad code that does not perform well, and that's the reason most SQL Server developers try to stay away from them and just use regular SQL statements.
Not really sure what the question is, but cursors are indeed dramatically sluggish on SQL Server when used on a row-2-row basis;
Post some specific code or question.
because databases work on sets not on looping. it is much faster to do this
update table set SomeCol = 'A'
where SomeDAte > '2010-01-01'
than writing a cursor and update this row by row
The only time I use cursors is if I have to do some maintenance like rebuilding or reorganizing an index