Why -avoiding cursor | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Why -avoiding cursor

Hi All, Why Peoples avoiding cursors in StoredProcedures. Regards
Mathi Mathivanan K
Performance is usually not too good, which can cause all kinds of locking issues in a production db. Cursors seem ‘natural’ to developers with a background in procedural programming, who are used to having to iterate through a recordset to get things done, and doing one thing at a time. T-SQL offers a lot of things you can do in a single batch, instead having to do it step by step and iterating through a recordset. The batch-oriented method is better known as the ‘set based’ approach. So there are actually two reasons why you should avoid cursors: performance and shortness of code. There will always be stuff that you can only do in cursors, but there is plenty more that can be done without cursors.
You can find many arricles such as this one if search at Articles Section
http://www.sql-server-performance.com/cursors.asp Madhivanan Failing to plan is Planning to fail
Counterquestion: Why do you want to use a cursor in a stored procedure anyway? —
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)

Good Question Frank [<img src=’/community/emoticons/emotion-2.gif’ alt=’:D‘ />][<img src=’/community/emoticons/emotion-2.gif’ alt=’:D‘ />]
Because They are trying to simulate the Client side coding (For, While loops) [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
Hi Madhivanan, Thanks. I learned lot. G[8] Mathivanan K
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by mkmathi</i><br /><br />Hi Madhivanan,<br /><br /> Thanks. I learned lot. G[8]<br /><br />Mathivanan K<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br />You are welcome [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br />Read as many articles as you can<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
]]>