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!
Have a look at Performance Tuning SQL Server Cursors
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
精彩评论