• Slick84 (11/24/2009)


    Hello,

    I'm trying to trim the trailing spaces in my column data using below t-sql.

    MAX(LTRIM(RTRIM(column_Name)))

    Addt'l info, I use the max keyword to successfully group my data. Could the max be effecting the trimming functionality?

    Problem is even after using the above t-sql, the column data's trailing spaces do not get trimmed. Screenshot attached. Please look at the fourth column from the right.

    Thanks,

    S

    MAX doesn't affect the trimming functionality. It's your column value; it has a bracket (']') that's causing the issue. RTRIM will removes spaces after ']' not before that.

    Try this:

    MAX(RTRIM(LTRIM(REPLACE(column_name,']','')))+']')

    HTH,

    Supriya

    Edit: You should have said so in the first place. :pinch:. Just looking at the attached screenshot it seemed like the brackets are part of the column values. Can you maybe share your select query? (without adding the brackets, of course)