• Richard Tatterton (6/25/2010)


    Adam Haines (6/25/2010)


    While this is true.... a string is a string, but the deviation here is the method used to evaluate the strings. Part of the ANSI standard is to make strings evaluated with "=" the same length before comparison and this is not a requirement for pattern matching. Like uses pattern matches so the string does not have to be equal.

    Maybe it is the ANSI standard to do so, in which case I expand my dislike from SQL Server to ANSI. I seriously cannot understand how an implicit truncation of spaces is helpful. Like I said, a string is a string, whether the characters are ascii 32 or not. It doesn't take much to truncate the trailing spaces yourself if you need to do it.

    Most (if not all) programming languages I've developed in so far in my 30-odd years have followed this procedure, and it works well. Not only well, but it's just intuitively correct, unlike this.

    If you've been at this game for three decades, then you must have used COBOL. Think of how that language handles trailing spaces in comparisons. Or is it not one of the "Most...languages"? For these data:

    01 String-Fields.

    05 String-1 Pic X(20) Value 'Hello'.

    05 String-2 Pic X(40) Value 'Hello '.

    ... would you not expect a this to come back as "True"?

    If String-1 = String-2

    Display "True"

    Else Display "Not a match".

    Of course, it resolves as "True" due to implicit padding of the shorter element to match the length of the longer one. It seems to me to be pretty much the same thing that MS SQL does.

    It's the "LIKE" operation that's a bit different, and it is different by design with good reason, as I think I demonstrated in my previous post. If you don't like "LIKE", so be it, but that hardly seems a logical reason to bash SQL syntax and string-handling standards that actually are pretty much the same as those in other languages.