December 19, 2022 at 8:27 pm
For me, the following priority is important and my priority - so we will never agree! 1. The statement returns the correct result with the current data. 2. The statement gives the correct result tomorrow. Evaluate with data that the definition allows inserted into the tables but does not currently exist. 3. The statement is maintenance friendly. 4. The performance of the statement is acceptable.
Happy Christmas! I will travel to Paris!!!
But Scott's solution is only 6 lines of code, yours is about 25 lines, so Scott's is arguably a lot more maintainable than yours. It also runs 60 times faster and to my knowledge they all return the correct result.
December 19, 2022 at 8:30 pm
And if you want the seven last?
December 19, 2022 at 8:43 pm
No, a solution like this is hopefully only on few rows - as mentioned earlier, else change the way to solve the problem. And if my solution runs in 10 seconds - what is the problem? And hopefully only one or few times a day! The CROSS APPLY have a statement for the last, another for the second last, another for the third last and one for the first. Hopefully not any changes in the data!!!! If the data is not selected at insert time, it must be because the other values are used in other solution!
December 19, 2022 at 8:46 pm
No, a solution like this is hopefully only on few rows - as mentioned earlier, else change the way to solve the problem. And if my solution runs in 10 seconds - what is the problem? And hopefully only one or few times a day! The CROSS APPLY have a statement for the last, another for the second last, another for the third last and one for the first. Hopefully not any changes in the data!!!! If the data is not selected at insert time, it must be because the other values are used in other solution!
Actually my code was written explicitly to make it handle data changes well while also being efficient.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
December 19, 2022 at 8:50 pm
No, a solution like this is hopefully only on few rows - as mentioned earlier, else change the way to solve the problem. And if my solution runs in 10 seconds - what is the problem? And hopefully only one or few times a day! The CROSS APPLY have a statement for the last, another for the second last, another for the third last and one for the first. Hopefully not any changes in the data!!!! If the data is not selected at insert time, it must be because the other values are used in other solution!
I don't know how you know that this is only for a few rows, will only need to be run a few times a day and might later need to be changed to extract from a different position within the string?
December 19, 2022 at 8:52 pm
Hopefully 10 seconds few times a day is a problem on you server!!!!
December 19, 2022 at 8:56 pm
Else the whole solution is wrong!
December 20, 2022 at 5:09 am
Hopefully 10 seconds few times a day is a problem on you server!!!!
It's not... but the attitude that will cause everything to be written in such a fashion, or worse, is.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 20, 2022 at 6:56 am
I have seen - and being removed - because I told
Attitude? It is OK for me to be removed from different threads because I not agree - yes, a positive attitude but a bad attitude only having one solution and call others many different things - it has happened for me many times - because only one solution can be used - never. And I do not imply that using tally as the only solution is bad, just showing other solutions. All possibilities in the language can be used and all problems are not solved the same way!!!!! And performance is not always the only goal, but quality is for me always vary important!!!!
December 21, 2022 at 12:57 am
Fascinating discussions, but what was "wrong" with my solution? I heard stuff like it is not usable except on SQL 2022, but this IS the SQL 2022 forum, is it not? So why not use the 3rd parameter, and keep the other solutions down in the pre-2022 forums, where hopefully people not using 2022 are looking anyway. I'd think we'd want to learn and use 2022's new features/advantages and share them in this forum.
December 21, 2022 at 1:06 am
Fascinating discussions, but what was "wrong" with my solution? I heard stuff like it is not usable except on SQL 2022, but this IS the SQL 2022 forum, is it not? So why not use the 3rd parameter, and keep the other solutions down in the pre-2022 forums, where hopefully people not using 2022 are looking anyway. I'd think we'd want to learn and use 2022's new features/advantages and share them in this forum.
I couldn't test it as I don't have SQL 2022 installed. Your solution looks fine though.
December 21, 2022 at 11:23 am
Fascinating discussions, but what was "wrong" with my solution? I heard stuff like it is not usable except on SQL 2022, but this IS the SQL 2022 forum, is it not? So why not use the 3rd parameter, and keep the other solutions down in the pre-2022 forums, where hopefully people not using 2022 are looking anyway. I'd think we'd want to learn and use 2022's new features/advantages and share them in this forum.
It would be interesting if you would use the test harness I posted earlier, add your solution and post the results.
I don't have SQL Server 2022 yet.
December 21, 2022 at 4:06 pm
It is OK for me to be removed from different threads because I not agree?
Absolutely not. Where did that happen? Was it on this this thread? Was it the one that was "Removed as SPAM" just a couple of posts above? I can have the WebMaster restore you can point it out.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 14 posts - 31 through 44 (of 44 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy