• (nodebb)

    Also, LEN gets the right trimmed length already; if it was a string ' abc ' or 'abc ' or 'abcd', the result would be 4. Which is why if you need un-trimmed length, you do LEN(@str + 'x') - 1.

  • MIKE (unregistered)

    Common funk intervals are root, fifth, minor seventh and octave or root fourth root fourth tritone root tritone root

  • RLB (unregistered)

    I'm sure you meant https://www.youtube.com/watch?v=iAmx_XdQky8, Remy...

  • Edd (unregistered)

    Someone changed ints to strings after yesterday's WTF

  • Duston (unregistered)

    I always declare my filenames as ints. Saves memory that way.

  • Scott (unregistered)

    Don't ascribe to malice (or, in this case, obfuscation) that which can adequately be explained by stupidity.

    Actually, the parameter probably started out life as a string, then got changed to int, and nobody noticed this line could be removed.

  • (nodebb) in reply to Mr. TA

    LEN gets the right trimmed length already

    Sure, but the whole thing is overcomplicated. This is equivalent:

    IF @funky_interval = '' SET @funky_interval = NULL
    

    Even if we don't rely on the MSSQL quirk that trailing spaces don't count for comparison purposes, there's no point in LTRIM and RTRIM because you're looking for strings with nothing but spaces... so either will return empty string, no need for both. So, minus quirk, this is still much easier to read:

    IF RTRIM(@funky_interval) = '' SET @funky_interval = NULL
    
  • WTFGuy (unregistered)

    @Duston ref

    I always declare my filenames as ints. Saves memory that way.

    If you restrict yourself to 8.3 names you can use shorts instead of ints and save even more memory. ;)

  • Sonu (unregistered)
    Comment held for moderation.
  • Sonu (unregistered)
    Comment held for moderation.
  • Naomi (unregistered) in reply to Mr. TA

    This just might be the realest RWTF.

  • (nodebb) in reply to Mr. TA

    Also, LEN gets the right trimmed length already; if it was a string ' abc ' or 'abc ' or 'abcd', the result would be 4. Which is why if you need un-trimmed length, you do LEN(@str + 'x') - 1.

    That's a huge WTF right there. If I want right-trimmed length, I should have to explicitly ask for that

  • I dunno LOL ¯\(°_o)/¯ (unregistered) in reply to WTFGuy

    If you're using 8.3 file names, those are floats, right? Or was that left?

  • Sonu (unregistered)
    Comment held for moderation.
  • (nodebb) in reply to Jack Penick

    The reasons are found in ancient history, when fixed-width space-padded fields (on 80-column punch cards) were the norm.

  • MiserableOldGit (unregistered) in reply to Jack Penick

    They have a command DATALENGTH() to do this. Although, I very much agree that using a function name that matches a squillion other languages, and then having it behave in a subtly different way is a huge WTF ... even if the impact rarely an issue.

    I have worked with SQL for years and didn't actually remember this (maybe I have come across it before, and forgot, like so many other things!). But then why would I look LEN() up in the language definition when it "seems" to behave as I'd expect?

  • RLB (unregistered) in reply to Watson

    The reasons are found in ancient history, when fixed-width space-padded fields (on 80-column punch cards) were the norm.

    Undoubtedly, but that itself is the WTF. Punch card compatibility is an excuse (and occasionally even a reasonable one) for COBOL, not for SQL.

  • Klimax (unregistered) in reply to RLB

    It was developed by IBM in 70s. Old enough to need to deal with such things...

  • WTFGuy (unregistered) in reply to MiserableOldGit

    @MiserableOldGit ref

    They have a command DATALENGTH() to do this.

    Not really. LEN() is expressed in logical characters. DATALENGTH() returns the number of bytes of actual storage used. So depending on the encoding, which Unicode character plane(s), combining diacritics, etc., those two can be very different numbers even if trailing spaces are not an issue.

  • Geri (unregistered) in reply to MIKE

    The probability of the root of a number being an INT tends to zero.

  • kaewberg (unregistered) in reply to Mr. TA

    Not for a char() column, surely?

  • Alexander Carlos (google)
    Comment held for moderation.
  • Alexander Carlos (google)
    Comment held for moderation.

Leave a comment on “Getting Funky”

Log In or post as a guest

Replying to comment #:

« Return to Article