March 3, 2009 at 5:44 am
Jeff Moden (3/3/2009)
[font="Arial Black"]Dugi... [/font]if I may suggest, it's better to give someone no answer than to give them what might be one of the worst answers for replacing cursors. Temp Tables and While loops are not the answer to replacing cursors. the reason why people want/need to replace cursors is mostly because of performance problems... Temp Table/While loop combinations do not solve that problem...
Jeff,
When you reply after my post, suddenly I remember that you have the Tally Table explanation also with performance, and I red again just to remember all things that you can do with Tally Table! I just reply again with suggestion about your Tally Table. And finally as I can see your explain that the While Loop doesn't replace cursor when we discuss about performance!!!
I think that now everything is ok!
Have nice day My Friend!
Dugi
March 3, 2009 at 3:36 pm
But.... just to be clear, Dugi... this one doesn't have anything to with a Tally table... just good programming.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 4, 2009 at 8:28 am
Basically using this technique,
of Using an extra column with ID from our Data from 1 to NROWS and processing the row with ID equal to
current row number, at each while iteraction... could work for almost any kind of sp that uses N-Cursors , its a matter of changing the logic using FETCHS to a While's based LOGIC.
Thanks a lot :).
Cheers
March 4, 2009 at 8:51 am
joao.rolo.sa (3/4/2009)
Basically using this technique,of Using an extra column with ID from our Data from 1 to NROWS and processing the row with ID equal to
current row number, at each while iteraction... could work for almost any kind of sp that uses N-Cursors , its a matter of changing the logic using FETCHS to a While's based LOGIC.
Thanks a lot :).
Cheers
Joao, if you look at the avatar of the post above yours, you will see the acronym RBAR, which is a 'Modenism' for "row by agonizing row".
Changing one RBAR mechanism for another RBAR mechanism is a waste of developer time, expensive time which could instead be spent converting the code to a fast and efficient set-based method.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply