1. Before the cursor, create a temp table or table variable.
2. Inside the loop, instead of selecting the data, insert it in to the temp table.
3. After the loop, select the data from the temp table.
-George
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
because a database is meant to be used in terms of sets not in terms of rows
99% of the time there is no need for cursors at all.
a cursor processes the reultds 1 row at atime while a set based solution does all the rows in 1 shot (which is many times faster)
Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
[small]----signature below----[/small]
Who are you, and why should I care?
Side A: We're a community of outdated robots who refused to upgrade and came here
*changes sides*
Side B: to live a simpler existence. Free of technology.
Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B> bites again.[/small]
OK...I've seen the Uncle Rico Tongue-Lashing twice in one day. Actually three times if I count the link to the original Uncle Rico google post (where I suspect Uncle Rico still lurks).
We get it. OK? Cursors are "Evil".
But I seem to remember when I registered here...something about this forum that was supposed to be different. The impression I had was that even those of us who are green or who had been led down the evil cursor path would be welcomed and not ridiculed.
Being laughed at...even when it's by an electronic jumpy, bouncing, purple thingy SUCKS!
I greatly appreciate the help I've received here.
Personally, I've never used cursors...Thank God! I might have been laughed right out off the forum.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.