Appending a "0" to zip code field

  • I need to update a zip code file by appending a zero to the beginning of the zip code?  For example, if the State = 'ME' and the zipcode starts is "4%", I need to update the results so that they all begin with '04%'. Any idea how I can do this to all zipcodes?

     

  • Zip codes are 5 chars long. So you want to prefix any zip codes < 5 chars with zeros? That would be better.

    If not, and it needs to be more specific (as in your example) then try the case statement.

    update mytable

    Set zipcode = case when State = 'ME' and zipcode like '4%' then '0' + Zipcode else zipcode end

     

  • Thank you for helping me in "duh" moment.

    Darla

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

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