Data manipulation problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soonerpgh
    New Member
    • Apr 2008
    • 23

    Data manipulation problem

    Hello, all. I am a fairly basic SQL user, meaning I can do most of the average queries and what all, but I have an issue that I have no idea how to tackle. I have a zip code field in my DB that has the four-digit extension at the end so instead of looking like 90210, it is 902100000. All of the extensions have four zeros and I want to simply drop the four zeros. There are a few that were apparently entered manually instead of programatically that do not have the extension at all. So I want to drop the extension from those that have it while leaving the 5 digit zip codes alone. How would I write this update query?
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Remember: once executed you can not revert back to it's old value. So better have a backup.

    Try:

    Code:
    UPDATE YourZipTable
    set ZipCode = left(ZipCode,5)
    -- CK

    Comment

    • soonerpgh
      New Member
      • Apr 2008
      • 23

      #3
      Thank you very much. That looks like exactly what I needed.

      Edit: Yep, that was it. Thank you so much.

      Comment

      Working...