• daveriya (10/21/2011)


    hi

    i have this code in where clause RTRIM(LTRIM(ODER_ID))= ' ',WHAT THis do

    It's just removing extra blank spaces, but this is un-necessary as SQL views empty strings as empty strings regardless how many spaces there are.

    So if your query is trying to return only empty strings, then you dont need to trim.

    The code below highlights this, if SQL considered

    '' != ' '

    the above to be true, then the penultimate select query would only return 1 row, but it returns 2.

    CREATE TABLE trimTest (

    value varchar(50)

    )

    INSERT INTO trimTest

    VALUES (''),

    (' ')

    SELECT *

    FROM trimTest

    SELECT *

    FROM trimTest

    WHERE value = ''

    SELECT *

    FROM trimTest

    WHERE LTRIM(RTRIM(value)) = ''

    http://sqlvince.blogspot.com/[/url]