Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jscot
Posting Yak Master
106 Posts |
Posted - 2010-06-16 : 18:01:43
|
| Hi, In general if we want to fetch the rows from a table or to update the existing rows we will use SELECT and UPDATE statements.What is the advantage if we use CURSORS?,ofcourse i know we can fetch or update the rows one by one with CURSORS.Can anybody give best example where we can use CURSORS in T-SQL programming or what is the main requirement to use CURSORS??Thanks in advance. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-06-16 : 18:06:26
|
quote: What is the advantage if we use CURSORS
None. |
 |
|
|
jscot
Posting Yak Master
106 Posts |
Posted - 2010-06-16 : 18:11:43
|
| so where we can use cursors? |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-06-16 : 18:25:45
|
| The best approach, IMHO anyway, is to pretend they don't exist. NEVER use them. It's the best way to develop a set-based mindset and to use SQL in the way it's intended.I often use an analogy described in here when I talk to people about them:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=72457http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47319I get a little repetitive but I believe it's a solid point. Cursors are a very bad habit and should be avoided as much as possible. The ONLY reason you should ever use one, is because all other methods have failed. And that means you've actually tried all other methods first. |
 |
|
|
|
|
|