- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
If you are going to do it dirty, at least use a loop and create dynamic SQL statements.
Admin
Wow... just... wow
Admin
You can do this in one line in Haskell
Admin
Loop? This saves the processing power required to do that. Talk about optimized. I want to learn from this guy.
Admin
Admin
If you even start writing this without thinking "there must be a better way", you're not a programmer, just a typist that knows SQL.
Admin
Ugggh! Blah Blah Blah : Paid by the line Blah Blah Blah : The real WTF is <Insert Ignorant Statement Here>
Yes... this is someone you should really learn from. If you can master this talented individuals' skills, you may even be able to work for Able's Car Wash writing a foxpro database to total daily inclome!
Admin
Correction... a typist who happens to know a website that displays sql code.
Admin
TLDR
captcha: minim (oh the irony)
Admin
At least he used temp tables.
Admin
I agree.
Admin
My reaction was "Oh god, please no", followed by "no, no, no, no..." as I continued to scroll down.
Admin
Somebody please shoot me now! Reading through this is causing me so much pain...
Admin
Who has time to write all this shit? PBTL?
Edit: On second look, I see no ;'s. Is that all 1 statement? Jesus.
Admin
String processing with SQL. What could possibly go wrong?
Admin
Breaking these up for readability:
Limiting this to looking at the last four characters would be trivial.
Admin
Admin
Admin
Whaaat?!??!
[image]Admin
TRWTF is that first name, last name, and initials are not separate fields in the table.
Gawd. I wonder how this mess would handle Mr. John Smith, Jr. DDS?
Admin
This can't be real
Admin
Admin
My mouse scroll wheel just gave me a blister.
Admin
My Krapometer redlined
Admin
Just GREAT!
Admin
This one is making my eyeballs bleed.
Admin
Hey, at least we now know what knives are for.
Stabbing idiots like this, that's what.
Admin
I don't know why but this looks like auto-generated code, it has to be auto-generated code, only an algorithm can be this DUMB!
From this we can conclude that the surname table column is VARCHAR(54) right? Luckily it was VARCHAR(255).
Admin
Some of the lesser sins that would merely have his code bounced in code review:
In this case, however, I think the correct course of action is job retraining. Preferably something involving paper hats, a fryolator, and a requirement that he wear a badge that reads "TRAINEE" for the first year.
Admin
Other people, when confronted with a problem like this think "Gee, I'll use regex!"
Oh look, a problem sanely solved.
Admin
String Parsing is really not a good idea in SQL. Its a performance killer. This looks like something that would be better suited in the application code. If a lot of string parsing has to be done in sql, its a candidate for SQLCLR.
That being said. There is a much better way to do this...
Admin
I think just the string processing
Admin
Admin
Hmm, I ain't a SQL expert, but dealing with strings is something on app side, not on SQL side, am I right?
Admin
Depends on the circumstances. There are better ways to do it on the SQL end as well. Under the circumstances however, given that it only transforms the output, it would definately be better to do this on the app end.
Admin
But on the plus side, they passed their typing final with flying colors! 666 words per second?
Admin
I could claim this is bullshit and the sender faked it... but I doubt he'd go into the trouble of creating this, so what I can say is...
... take this expert, and tie him. And bury him. Waist below into an ant's nest. Under a hornet's nest. And kick the hornets. Please.
Admin
This isn't a query, it's a war declaration!
Admin
It is what happens when you attempt to create Artificial Intelligence from Authentic Stupidity.
Admin
One word: OMG!
Admin
Exactly this
Admin
What an idiot. He should've used table variables.
Admin
God forbid writing a function that splits strings by space characters (while maybe uniforming space characters first).
Admin
That's all I could say when I was looking at the code. This is an epic WTF
Admin
(It was a camping trip and we had a shortage of silverware because we're stupid, but I had my Leatherman.)
Admin
I'm no expert either, but I'm speechless... By the way, cool name iToad...
Admin
Any fule no you have to use XML for really enterprisey string manipulation in SQL.
SELECT XmlName.value('FirstName[1]', 'varchar(30)'), XmlName.value('LastName[1]', 'varchar(30)') FROM ( SELECT XmlName = CAST('<FirstName>' + REPLACE(clinician_name, ' ', '</FirstName><LastName>') + '</LastName>' AS XML) FROM ( SELECT clinician_name = 'Bugs Bunny' UNION ALL SELECT 'Fred Flintstone' UNION ALL SELECT 'Barney Rubble' ) names ) split
Let values with anything other than exactly one space character be an exercise for the student.
Admin
Loop unrolling always gives you that critical performance boost.
Admin
The real WTF is posting all of it without any snipping.
Admin
This leads to a delicious vodka and orange infused cake.