Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2011
    Posts
    3

    Unanswered: Replacing first 9 characters in a column

    How can I replace the left most characters of a SSN to leave only the last four digets in the column?

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    substring(6,4) ???

    . . . but your question was unclear.

    You said you wanted to "replace the left most characters" but you also said that you want to "leave only the last four digits in the column." Both conditions cannot co-exist. Please expand on what you want.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Oct 2011
    Posts
    3

    Removing the left most charaters of a string

    Say for instance I want to leave the last four digits of a Social Security number in a field but take out the first six.

  4. #4
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Not knowing your table or column name, this is an approximation:

    Code:
    update  Table
    set     SSN=substring(SSN,6,4)
    from    dbo.Table
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  5. #5
    Join Date
    Oct 2011
    Posts
    3

    Removing the left most charaters of a string

    That worked. I was wasting my time with LTRIM. Thank you.

  6. #6
    Join Date
    Sep 2011
    Posts
    31
    LTRIM only removes leading spaces from a string where as you wanted to remove first 6 numbers from ssn

Posting Permissions

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