July 12, 2012 at 8:16 am
I used the while loop within while loop worked a treat for what i need :), thanks for all the SET based solutions but id used the loop to complete the task which it did in less than a second so im happy plenty to ponder for the future though :w00t:
***The first step is always the hardest *******
July 12, 2012 at 8:22 am
SGT_squeequal (7/12/2012)
I used the while loop within while loop worked a treat for what i need π
So with 5 other methods that are faster you still choose to use the slow looping version? :w00t:
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 β Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 12, 2012 at 8:26 am
i used the loop before any of the set based ooptions appeard plenty to ponder for the future :);-)
***The first step is always the hardest *******
July 12, 2012 at 8:28 am
SGT_squeequal (7/12/2012)
i used the loop before any of the set based ooptions appeard plenty to ponder for the future :);-)
And that is a reason to not change which method you use?
July 12, 2012 at 8:29 am
Sean Lange (7/12/2012)
SGT_squeequal (7/12/2012)
I used the while loop within while loop worked a treat for what i need πSo with 5 other methods that are faster you still choose to use the slow looping version? :w00t:
Not only faster, but more compact as well.
π
July 12, 2012 at 8:32 am
SGT_squeequal (7/12/2012)
i used the loop before any of the set based ooptions appeard plenty to ponder for the future :);-)
If you chose a looping method over 5 faster, simpler set-based methods while on my watch, you'd have all the time in the world to ponder the future - at home.
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
July 12, 2012 at 9:17 am
I dont really know how to take your remark, are you being a popmus git, just showing off or trying to help? mmm
will grant, that set based, over loop is more efficient but, at the end of the day it gets dark and the job needs doing. The while loop worked perfect for my task, so it matters not what way i completed the task as long as it was completed within time frame given.
Thanks to all of you who posted constructive and helpfull comments, im not a SQL developer but i do my bit.
***The first step is always the hardest *******
July 12, 2012 at 9:44 am
Not all experienced SQL Server developers appreciate the importance of code performance - as a relative newcomer it may have passed you by, even after lurking around here for a while.
I apologise if the remark has caused personal offence, however I would urge that you take the intent on board. I'm not alone on this thread in expressing surprise that you chose a looping 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
July 12, 2012 at 9:51 am
SGT_squeequal (7/12/2012)
I dont really know how to take your remark, are you being a popmus git, just showing off or trying to help? mmmwill grant, that set based, over loop is more efficient but, at the end of the day it gets dark and the job needs doing. The while loop worked perfect for my task, so it matters not what way i completed the task as long as it was completed within time frame given.
Thanks to all of you who posted constructive and helpfull comments, im not a SQL developer but i do my bit.
Whom are you adressing? Actually, it doesn't matter. Folks are just trying to help.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 12, 2012 at 10:33 am
:hehe:
Jeff Moden (7/12/2012)
SGT_squeequal (7/12/2012)
I dont really know how to take your remark, are you being a popmus git, just showing off or trying to help? mmmwill grant, that set based, over loop is more efficient but, at the end of the day it gets dark and the job needs doing. The while loop worked perfect for my task, so it matters not what way i completed the task as long as it was completed within time frame given.
Thanks to all of you who posted constructive and helpfull comments, im not a SQL developer but i do my bit.
Whom are you adressing? Actually, it doesn't matter. Folks are just trying to help.
i was refering to ChrisM@Work comment,
If you chose a looping method over 5 faster, simpler set-based methods while on my watch, you'd have all the time in the world to ponder the future - at home.
@chris-2 i understand the need for perforamce however on this instance there was no real requirement your just going to have to trust me on that, i have looked at the other methods for future use and like the CTE way to complete the task. once again thank you all for your help it was and aways is appreciated.
EDIT PS
apology acceepted thanks to everyone
***The first step is always the hardest *******
July 12, 2012 at 6:21 pm
Sean Lange (7/12/2012)
SGT_squeequal (7/12/2012)
I used the while loop within while loop worked a treat for what i need πSo with 5 other methods that are faster you still choose to use the slow looping version? :w00t:
Clearly this must be one of the rare applications where high performance is not a non-functional requirement.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
July 12, 2012 at 10:34 pm
dwain.c (7/12/2012)
Sean Lange (7/12/2012)
SGT_squeequal (7/12/2012)
I used the while loop within while loop worked a treat for what i need πSo with 5 other methods that are faster you still choose to use the slow looping version? :w00t:
Clearly this must be one of the rare applications where high performance is not a non-functional requirement.
Agreed but consider that taking every opportunity to do it the right way will make you better when it really does need to be right. It's kind of like practicing the piano. Unless you're in the business of being a comedian, you just don't practice hitting the wrong notes.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 12, 2012 at 10:48 pm
Jeff Moden (7/12/2012)
dwain.c (7/12/2012)
Sean Lange (7/12/2012)
SGT_squeequal (7/12/2012)
I used the while loop within while loop worked a treat for what i need πSo with 5 other methods that are faster you still choose to use the slow looping version? :w00t:
Clearly this must be one of the rare applications where high performance is not a non-functional requirement.
Agreed but consider that taking every opportunity to do it the right way will make you better when it really does need to be right. It's kind of like practicing the piano. Unless you're in the business of being a comedian, you just don't practice hitting the wrong notes.
I guess, omitting the smiley from my post, also lost the irony of my statement. π
C'mon now - that was funny wasn't it?
I can name that tune in 5 off-key notes!
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
July 13, 2012 at 7:02 am
Heh... I've gotten in trouble with some folks by using emoticons. Decided to try not using them for a while. Guess that's not working so well, either. :hehe:
--Jeff Moden
Change is inevitable... Change for the better is not.
July 13, 2012 at 12:12 pm
as today is the 13th its a good day my lucky day π other day was a dark day lol π
***The first step is always the hardest *******
Viewing 15 posts - 16 through 30 (of 30 total)
You must be logged in to reply to this topic. Login to reply