Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

SQL update statement based on a formula?

in my table PostalCodes i need to select all Postalcodes from dbo.postalcodes where LEN = 4, and then add a leading 0 (zero) in front of value and re-update it.

For example, postal codes in the table that look like this:  7712  should actually be 07712

Anyone know how to do this?
0
arthurh88
Asked:
arthurh88
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
update postalcodes
set postalcode = '0' + postalcode
where len(postalcode) = 4
0
 
arthurh88Author Commented:
bah!  i should have figured this one out :)  Thanks!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now