Author |
Topic |
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2007-10-23 : 04:10:13
|
Hi All,this is my first post on this site.Whoever is looking in this post plz give me some idea about Cursors in Sqlserver how they works and from where should i start to get perfection in cursors in sqlserverregards,Rahul |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-10-23 : 04:14:11
|
just key in CURSOR in the Google Custom Search box on the upper right of this screen and hit Search KH[spoiler]Time is always against us[/spoiler] |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-10-23 : 04:16:25
|
But a general advice is, try to perfect your Select Query before looking at cursor. 99% of the time you don't need cursor at all. 1st Priority is to learn Set-Based Query. Once you have perfect that, then take a peep at cursor.  KH[spoiler]Time is always against us[/spoiler] |
 |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2007-10-23 : 04:55:32
|
The main problem with cursors is that it is a row by row processing which creates a network roundtrip at every row. Whereas the set based approach will return the whole recordsetJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-23 : 05:28:13
|
Even if you have a CURSOR inside a Stored Procedure and you only call then SP?Where comes the roundtrip in then? E 12°55'05.25"N 56°04'39.16" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-23 : 05:31:55
|
quote: Originally posted by arorarahul.0688 Hi All,this is my first post on this site.Whoever is looking in this post plz give me some idea about Cursors in Sqlserver how they works and from where should i start to get perfection in cursors in sqlserverregards,Rahul
Which is your previous RDBMS?MadhivananFailing to plan is Planning to fail |
 |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2007-10-23 : 11:48:23
|
Peso , in the instance of a CURSOR within a SP and you only then call SP , in that case you don't have a network roundtrip. I was trying to make the point of row by row processing , in a certain situationJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-10-23 : 12:43:17
|
You have a round trip to the database engine and it also cannot optimise the query for the final result.Sometimes a cursor can be marginally faster but usually it's thousands (or millions or more) of times slower.==========================================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. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-24 : 02:50:57
|
quote: Originally posted by nr You have a round trip to the database engine and it also cannot optimise the query for the final result.Sometimes a cursor can be marginally faster but usually it's thousands (or millions or more) of times slower.==========================================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.
By sometimes, did you mean "Genereating Running total using a cursor"? MadhivananFailing to plan is Planning to fail |
 |
|
|