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 |
|
mageshks
Yak Posting Veteran
59 Posts |
Posted - 2007-08-09 : 02:18:35
|
| I have a basic question.When cursors become unavoidable?.People suggesting that WHILE can be replaced by CURSOR.Then Why cursors in SQL server?Thanks in advance. |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2007-08-09 : 02:31:02
|
| temp tables, table variables, set based approaches are all ways to avoid using cursors. I have not run into a situation where a cursor could not be replaced by one of these 3 methods. Although it might be possible that there a scenario exists that does actually require a cursor.I think cursor support in newer versions of sql exists just for backwards compatibility and legacy support. Cursors are even part of the ansi/iso sql standard, so it is possible they are still supported in the latest releases of SQL server to ease migrating code from one environment to another (oracle to sql server for example).-ec |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-08-09 : 04:15:22
|
| >> When cursors become unavoidable?Never>> Then Why cursors in SQL server?They are part of the (now less important) ansi standardThey are handy for non-datbase coders who think in procedural terms.There are a lot of features in sql server that are not necessary.e.g. addition is an unnecessary operator but you will rarely (but sometimes do) see a language that doesn't include it.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|