By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,363 Members | 2,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,363 IT Pros & Developers. It's quick & easy.

Data manipulation problem

P: 23
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?
Apr 1 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 2,878
Remember: once executed you can not revert back to it's old value. So better have a backup.


Expand|Select|Wrap|Line Numbers
  1. UPDATE YourZipTable
  2. set ZipCode = left(ZipCode,5)
-- CK
Apr 1 '08 #2

P: 23
Thank you very much. That looks like exactly what I needed.

Edit: Yep, that was it. Thank you so much.
Apr 1 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.