Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100

    Unanswered: RTrim and LTrim with UPDATE

    You all have been so much help, but I've discovered yet another problem. I'm trying to clean up my table using the following command:
    Code:
    UPDATE dbo.TableName
    SET First_Name = LTrim(RTrim(First_Name))
    But it does not seem to have any effect. Thoughts? Thanks!
    BillS

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Should work fine. It's possible that your string has characters that appear as spaces, but which are actually a different ASCII value.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    Thr LTrim function works fine when I use it in conjunction with SELECT, just not UPDATE.
    BillS

  4. #4
    Join Date
    Dec 2002
    Posts
    1,245
    Quote Originally Posted by BillSinc
    Thr LTrim function works fine when I use it in conjunction with SELECT, just not UPDATE.
    Is it possible you are dealing with a char (and not a varchar) column?

    Regards,

    hmscott
    Have you hugged your backup today?

  5. #5
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    Yes, that's correct. Is that wrong?
    BillS

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Char is fixed length, so your data will be padded.
    Better to use varchar in this situation.
    In fact, char should only be used when the length is fixed and is under about 10 characters.
    These days, zip codes are one of the few elements I store as char.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    Thanks, I originally switched from NVARCHAR, so I will update the tables..
    BillS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •