REVERSE(SUBSTRING(wtf))



  • My current favorite stored procedure in our code base.



    SELECT WBSID, REVERSE(SUBSTRING(REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6), <br>
    				PATINDEX('%[^.]%', REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6)), 25)) + ' | ' + description AS MasterWBS <br>
    FROM WBSMasterTbl<br>
    WHERE Display = 'True'<br>
    ORDER BY MasterWBS<br>


  • Moments like that are when I put my hands on the desk, push myself back, and don my thousand-mile stare all the way to the coffee machine and back.



  • @theflin said:

    My current favorite stored procedure in our code base.



    SELECT WBSID, REVERSE(SUBSTRING(REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6), <br>
    				PATINDEX('%[^.]%', REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6)), 25)) + ' | ' + description AS MasterWBS <br>
    FROM WBSMasterTbl<br>
    <b>WHERE Display = 'True'</b><br>
    ORDER BY MasterWBS<br></blockquote>
    

    People can be mislead by the reverse part but behind the section in bold lies something far more dangerous.



  • Its not a Real WTF unless it also has an SQL injection vulnerability, and ulness that WHERE clause looked like this one-

    WHERE odered = 'True' OR odered = 'TRUE' OR odered = 'true'



  • @SamC said:

    Its not a Real WTF unless it also has an SQL injection vulnerability, and ulness that WHERE clause looked like this one-

    WHERE odered = 'True' OR odered = 'TRUE' OR odered = 'true'

    Depending on the collation, testing for case may be useless. Also I have no idea where that "odered" comes from, unles it's from Dyslexialand.



  • @SamC said:

    Its not a Real WTF unless it also has an SQL injection vulnerability, and ulness that WHERE clause looked like this one-

    WHERE odored = 'True' OR odored = 'TRUE' OR odored = 'true'

    FTFY



  • @dhromed said:

    Moments like that are when I put my hands on the desk, push myself back, and don my thousand-mile stare all the way to the coffee machine and back.
    That's a serious distance to go for just a bit of coffee. Can't they move it a bit closer; say, in the next state?

     



  • @theflin said:

    My current favorite stored procedure in our code base.



    SELECT WBSID, REVERSE(SUBSTRING(REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6), <br>
    				PATINDEX('%[^.]%', REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6)), 25)) + ' | ' + description AS MasterWBS <br>
    FROM WBSMasterTbl<br>
    WHERE Display = 'True'<br>
    ORDER BY MasterWBS<br></blockquote>&nbsp;</p><p mce_keep="true">To me it looks like a fine way to do string maching from the right of the string. One thing that SQL servers doesn't seem to be too good at out of the box.</p><p mce_keep="true">Reverse the string and reverse the search pattern and Bob's your uncle.</p><p mce_keep="true">Otherwise: What Ronald said.</p>


  • @Severity One said:

    @dhromed said:

    Moments like that are when I put my hands on the desk, push myself back, and don my thousand-mile stare all the way to the coffee machine and back.
    That's a serious distance to go for just a bit of coffee. Can't they move it a bit closer; say, in the next state?

     

    You should go to your local VA watering hole. You could pick up a female soldier that will let you do just about anything plus if she's back from one of the wars she'll possibly have that thousand-mile stare which you will then understand.



  • @Severity One said:

    @dhromed said:

    Moments like that are when I put my hands on the desk, push myself back, and don my thousand-mile stare all the way to the coffee machine and back.
    That's a serious distance to go for just a bit of coffee. Can't they move it a bit closer; say, in the next state?

     

    See other thread about crossing state lines with beverages.



  • @Ronald said:

    yet another lolpussy threadshit

    You think you're funny but you're not.

    Grow the fuck up.



  • @dsckeld said:

    @theflin said:

    My current favorite stored procedure in our code base.



    SELECT WBSID, REVERSE(SUBSTRING(REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6), <br>
    				PATINDEX('%[^.]%', REVERSE(level1 + '.' + level2 + '.' + level3 + '.' + <br>
    				level4 + '.' + level5 + '.' + level6)), 25)) + ' | ' + description AS MasterWBS <br>
    FROM WBSMasterTbl<br>
    WHERE Display = 'True'<br>
    ORDER BY MasterWBS<br></blockquote>&nbsp;</p><p>To me it looks like a fine way to do string maching from the right of the string. One thing that SQL servers doesn't seem to be too good at out of the box.</p><p>Reverse the string and reverse the search pattern and Bob's your uncle.</p><p>Otherwise: What Ronald said.</p></blockquote>
    

    The real WTF is people claiming this is not a WTF.

    What it seems to do (to me) is to remove trailing periods. Basically, if say level 4, 5 and 6 are empty, the concatenated string would become l1.l2.l3..., and this magic would fix it to be "l1.l2.l3". Even if this should, in some odd cases, be a good requirement (having a hardcoded 6 level depth as maximum), can't you, say:

    - Use some RTRIM function (not sure if whatever SQL this is has it)?

    - Simply concatenate some conditionals that are empty when levelX is empty, and ".levelX" if not?

    - Take a substring with as length the index of pattern '%[.]*$%'?

    Edit: Just googling for a bit for RTRIM-ing none-spaces in MSSQL brought me to this page. See the second post and compare ;-): http://stackoverflow.com/questions/7838676/sql-server-trim-character



  •  Actually it looks like a slightly more complex way of doing Subtring(string, len - 25, len).
    I.E. It's getting the last 25 characters of the string "level1 + '.' + level2 + '.' + level3 + '.' + level4 + '.' + level5 + '.' + level6"



  • @Ronald said:

    Depending on the collation, testing for case
    may be useless.
     

    Of course it's useless. What do you think this is, The Daily Best Code?

    If I recall correctly, the collation (for everything; literally every column but the primary key was a varchar) was latin1_ci. Which is a WTF in itself.

    @Ronald said:

    Also I have no idea where that "odered" comes from,
    unles it's from Dyslexialand.
     

    A produck is odered when a cusomer completes the ckekout process after adding their itoms to the shooping cart.



  • @flabdablet said:

    @Ronald said:
    yet another lolpussy threadshit

    You think you're funny but you're not.

    Grow the fuck up.

    I'm not sure what is a "lolpussy threadshit" but as funny goes even reading the phonebook is funnier than you pretending to be a bitter moron with bad manners. Once in a while I even wonder if you're pretending.



  • @SamC said:

    A produck is odered when a cusomer completes the ckekout process after adding their itoms to the shooping cart.

    Is that your Arnold Shwarzenneger impression?



  • @SamC said:

    the shooping cart.

    Shoop da woop, the Photoshop of horrors...

     



  • @Ronald said:

    but as funny goes even reading the phonebook is funnier than you pretending to be a bitter moron with bad manners.
     

    I'd rather play Creative Mode.



  • @dhromed said:

    @Ronald said:

    but as funny goes even reading the phonebook is funnier than you pretending to be a bitter moron with bad manners.
     

    I'd rather play Creative Mode.

    I'd take a dramatic reading of the phonebook over Minecraft any day.



  • @Ben L. said:

    I'd take a dramatic reading of the phonebook over Minecraft any day.
     

    Perhaps just for the curiosity factor.



  • @dhromed said:

    @Ben L. said:

    I'd take a dramatic reading of the phonebook over Minecraft any day.
     

    Perhaps just for the curiosity factor.

    Lot of characters, but the plot is a little thin.



  • @Ben L. said:

    @dhromed said:

    @Ronald said:

    but as funny goes even reading the phonebook is funnier than you pretending to be a bitter moron with bad manners.
     

    I'd rather play Creative Mode.

    I'd take a dramatic reading of the phonebook over Minecraft any day.

    what about a choir?



  • @Ronald said:

    @SamC said:
    A produck is odered when a cusomer completes the ckekout process after adding their itoms to the shooping cart.

    Is that your Arnold Shwarzenneger impression?

     

    Sadly, no. Those are the actual names, as given by the outsourcers, of the database tables and forms controllers that once ran a particular e-commerce site.



  • @dhromed said:

    @Ben L. said:

    I'd take a dramatic reading of the phonebook over Minecraft any day.
     

    Perhaps just for the curiosity factor.

    This shoud tide you over.



  • @Ben L. said:

    @dhromed said:

    @Ben L. said:

    I'd take a dramatic reading of the phonebook over Minecraft any day.
     

    Perhaps just for the curiosity factor.

    This shoud tide you over.

    This is the only funny video on Dreyfuss channel, and it has around 20,000 views. His other videos are more serious and they have like 50 views. That's what is wrong with America, people just want to have a good laugh, they don't care about civics and other important stuff [1].



    On his Youtube channel it's not obvious what is exactly his initiative so I went on his website and oh boy is that thing ugly.



    The worst of it:

    • The wooden frame with some white text on it
    • The Founding Fathers era theme which is not coherent with the semi-modern dynamic dropdown menu.
    • The video that is somehow blended with the barf-colored background
    • The actual content of the site which follows a slightly different design, with a blog layout (wide margins) and a lame old paper background (with visible repeat lines).



    [1] I don't either. His other videos are boring.



  • @Ben L. said:

    @dhromed said:

    @Ben L. said:

    I'd take a dramatic reading of the phonebook over Minecraft any day.
     

    Perhaps just for the curiosity factor.

    This shoud tide you over.

     

    This almost makes up for my brand new video card that's currently unusable becase the fan wasn't screwed on, out of the box. No wonder it fucking went RATATATATATA after I installed it, because then it's upside down and it was upheld by nothing but the thread of 1 loose screw, 1 firm power wire, a little bit of vanderwaals force, and a fair amount of wishful thinking.

    It's a really good card otherwise, though. Very compact. Really blows away my 4850, as expected.

     



  • @dhromed said:

    a little bit of vanderwaals force

    Does the Dutch Ministry of Science give you a Euro every time you name-drop a Dutch scientist?



  • @dhromed said:

    the fan wasn't screwed on
    @dhromed said:
    Really blows away
    bah dum tsh



  • @morbiuswilters said:

    @dhromed said:
    a little bit of vanderwaals force

    Does the Dutch Ministry of Science give you a Euro every time you name-drop a Dutch scientist?

     

    Of course not. Antonie van Leeuwenhoek.



  • @Ben L. said:

    @dhromed said:
    the fan wasn't screwed on
    @dhromed said:
    Really blows away
    bah dum tsh
     

    It took two weeks for them to unscrew-up my order, and now it's probably going to be another two weeks for the replacement. Goddamn.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.