• Andy (unregistered)

    This is the best one, yet. Unbelievable!

  • peter (unregistered)

    The obvious solution is to throw more hardware at it.

  • Manni (unregistered)

    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.

  • rs (unregistered)

    New Question:

    How long has this person been working with SQL?

    a) Less than 5 mins
    b) 5 to 30 mins
    c) 30+ mins

  • Dave Mays (unregistered)

    OMG. It's just wrong in so many ways I don't even know what to say.

  • Brad (unregistered)

    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!

  • Joshua Bair (unregistered)

    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

  • Jeff S (unregistered)

    A classic WTF, a definitely hall of famer !! I'd like to nominate this one for WTF-of-the-year so far !

  • Jeff S (unregistered)

    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 ....

  • skicow (unregistered)

    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.

  • Brendan Tompkins (unregistered)

    Okay skicow. But calling them a he/she is a little over the top! ;)

  • cm (unregistered)

    OMG-I-LMAO

    I agree with peter, a quad-processor with hyper-threading should make this run nicely ;-)

    Best one yet!!

  • Thomas (unregistered)

    You can use EXEC to run a SQL string in mssql.

  • Manni (unregistered)

    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.

  • Guayo (unregistered)

    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...

  • GROUP BY (unregistered)

    select question_text, answer_text, count(*) from tblAnswers
    group by question_text, answer_text


    WTF kind of a table name is "tblAnswers"?

  • Jeff S (unregistered)

    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)

  • Rojohn (unregistered)

    If Dijkstra were still alive, this might inspire a new letter to the ACM: Clipboard considered harmful.

  • Ray S (unregistered)

    Hey, I wonder if the guy that put this together was also responsible for the IsValidISBN function a week or two ago?

    Classic. :)

  • Raymond Lewallen (unregistered)

    Oh man, that is so freaking awesome!

  • John Kerry (unregistered)

    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...

  • TheF0o1 (unregistered)

    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.

  • MrWhatever (unregistered)

    SET @strSql = "DELETE FROM [Chair]"
    EXEC @strSql

  • Tim Cartwright (unregistered)

    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.....

  • Grand Diversion (unregistered)

    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!!

  • Jason Strate (unregistered)

    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.

  • ESH (unregistered)

    I see code like this every day. I maintain it, I know the original author.

    This is not, I repeat, is not an exaggeration

  • the amazing null (unregistered) in reply to cm

    hyperthreading + ms sql server.... ouch. more thrashing than a million megadeth concerts. i hope to never have to do that... again.

Leave a comment on “It seems my app is running a little slow ...”

Log In or post as a guest

Replying to comment #24313:

« Return to Article