Remove trailing Blanks? RTRIM?

  • I'm trying to compress my last and first names so they look good on my report without big gaps. Is there a way to trim the trailing spaces after my last name field?

    desired output:

    ex: last_name, first_name

    I've tried to substring it, right, left commands

  • It should be as easy as:

    select

    rtrim(t.last_name) + ', ' + rtrim(t.first_name) as name

    from table t

     

    If that doesn't work the way you want, post your SQL, the output and information about the front-end software in use.

  • I'd go a bit further:

    select

    ltrim(rtrim(t.last_name) )+ ', ' + ltrim(rtrim(t.first_name)) as name

    from table t

     

    and even further:

    DO ALL TRIMING Client side before it gets into the DB!!

    Cheers,

     


    * Noel

  • Damn, you guys are quick. By the time I figured it out, I had 2 great replies. Thanks!!!

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

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