- 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
This is the best one, yet. Unbelievable!
Admin
The obvious solution is to throw more hardware at it.
Admin
Doesn't anyone realize how efficient this is? Instead of making SQL return potential results or run through a loop, you just tell it EXACTLY what you're looking for. I suppose you could run into problems down the line if a question were to change, but what are the chances of that? People only use databases when something is set up and will never EVER change.
If you get paid per line of code, this is perfect! And what about when more questions are added? You don't want some automated system taking your job do you? This will require manual coding to account for the new question(s). This programmer deserves an award.
Admin
New Question:
How long has this person been working with SQL?
a) Less than 5 mins
b) 5 to 30 mins
c) 30+ mins
Admin
OMG. It's just wrong in so many ways I don't even know what to say.
Admin
hahahaha
(breathe)
hahahaha
Best one in a long time.
My favorite line:
"SQL for questions 4 to 49 snipped... (Just use your imagination)"
Must have taken him years to type this all out. I'd say he must have had scripts to generate the code, but that would be giving him WAY too much credit.
And its not only this SQL, but WTF is he doing storing the full text of THE QUESTION with EVERY ANSWER!
Admin
Hope he didn't MISSPELL anything.
That reminds me. I just saw a proposed report engine that stored the SQL statements in SQL Tables. The statements were loaded by code, then sent BACK to the server to get the actual data. The plan, apparently, was to allow the user to write his own SQL Statments to generate whatever reports he wanted.
I suggested that we just put the source code that reads the database IN the database, so that the user could modify that as well. No one laughed...
- Joshua
Admin
A classic WTF, a definitely hall of famer !! I'd like to nominate this one for WTF-of-the-year so far !
Admin
Actually -- does this actually execute? Is this MS SQL Server ? If so, I don't think any of those EXEC calls are legal, I believe EXEC in that format requires a stored procedure name and would set the variable being assigned to the returned value from the proc, not from a value in the recordset returned ....
Admin
Great merciful crap. O_o
Is he actually doing anything with the totals for each question that he is querying? He/She is displaying the number of yes/no results but not the total number of results per question....Meh.
Admin
Okay skicow. But calling them a he/she is a little over the top! ;)
Admin
OMG-I-LMAO
I agree with peter, a quad-processor with hyper-threading should make this run nicely ;-)
Best one yet!!
Admin
You can use EXEC to run a SQL string in mssql.
Admin
I think we can forego asking whether or not the code works. In lots of code posts I've seen at least one person say "This shouldn't even run!" The code runs, or it wouldn't be used and therefore wouldn't be a WTF.
The basis of our mockery is in the fact that the code is WAY overblown and could be done with simple loops or reduced down to a query or two. Either that or as skicow pointed out, that the programmer is adding steps like getting the total number of questions via 50 separate queries and then doing nothing with the information.
Admin
I'm surprised he didn't named his stored proc variables like:
@iQ1_Did_any_associate_verbally_acknowledge_you_within_30_seconds_after_you_entered_the_store_Total
@iQ1_Did_any_associate_verbally_acknowledge_you_within_30_seconds_after_you_entered_the_store_Yes
and so on...
Admin
select question_text, answer_text, count(*) from tblAnswers
group by question_text, answer_text
WTF kind of a table name is "tblAnswers"?
Admin
Yes, Thomas, but if you cannot use EXEC to set a variable like this code attempts to do with MSSQL, as I mention. For example, this works:
declare @Sql varchar(100);
set @SQL = 'select 1'
EXEC (@SQL)
but this does not:
declare @i int;
declare @SQL varchar(1000);
set @SQL='select 1'
exec @i = @SQL
which is what the code is attempting to do, unless I am missing something ....
(cut and paste either into Query Analyzer to see for yourself)
Admin
If Dijkstra were still alive, this might inspire a new letter to the ACM: Clipboard considered harmful.
Admin
Hey, I wonder if the guy that put this together was also responsible for the IsValidISBN function a week or two ago?
Classic. :)
Admin
Oh man, that is so freaking awesome!
Admin
With my code plan I would have retrieved the records in 4 milliseconds... This coder has obviously mislead his client...
Wrong code...
Wrong place...
Wrong Time...
Admin
I have to believe that this was generated code. But then either the writer(s) of the code generator committed a WTF or it's being used as not originally intended, which is still a WTF.
The only real explanation is that "@iQ1Total" in fact describes the intelligence of the person who wrote this.
Admin
SET @strSql = "DELETE FROM [Chair]"
EXEC @strSql
Admin
Jeff S is right, that code will NOT run in sql server. Unless that is some other query engine that will allow that. So that is probably dead code that does not get executed, even though it is beyond atrocious.....
Admin
Wow.
Looks like the result of a marketing person wannabe programmer trying to make themselves a survey. :P
"WTF kind of a table name is "tblAnswers"?"
I'm assuming that "tbl" is Hungarian notation for Table. This is a Table of Answers. Duh! Just so you don't get confused and think it was a view, function or even a stored procedure. LOL!!
Admin
Scary. I thought the script tables and data in our databases were pretty bad.
"WTF kind of a table name is "tblAnswers"?"
We use Hungarian notation on tables here and it drives a few people crazy but it makes sense to me. But then all database objects here have to fit a naming standard.
Admin
I see code like this every day. I maintain it, I know the original author.
This is not, I repeat, is not an exaggeration
Admin
hyperthreading + ms sql server.... ouch. more thrashing than a million megadeth concerts. i hope to never have to do that... again.