LTRIM/RTRIM

  • Hi Team,

    using below script to read two column from a text file and trying to trim the spaces for file_name.

    but trimming is not happening

    bulk insert #O_P

    from 'C:\Users\TKT\\PA.txt'

    with (fieldterminator = ',',rowterminator = '')

    END

    INSERT INTO O_P (file_name,location)

    SELECT LTRIM(RTRIM(file_name)), location From #O_P

    Please help

  • What do you mean "trim is not happening"? Do you still see the whitespace chars? Are you sure it's a whitespace? It could be any other non-representable char: check what ASCII(char) returns.

    -- Gianluca Sartori

  • Check up what shpaghettidba suggested to, and you can additionally use the REPLACE() function to replace those non-visible characters (usually char(9), char(10) and char(13)) with whitespaces and then TRIM them.

    Igor Micev,My blog: www.igormicev.com

  • Check UNICODE() of the problem symbol and collation. Under some collations ASCII=32 doesn't mean UNICODE =32 which is required for trim() functions.

  • serg-52 (4/23/2015)


    Check UNICODE() of the problem symbol and collation. Under some collations ASCII=32 doesn't mean UNICODE =32 which is required for trim() functions.

    Great catch!

    -- Gianluca Sartori

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply