Solved

formatting character zip code to numeric zip code in SQL (SQL SERVER)

Posted on 2013-06-21
3
455 Views
Last Modified: 2013-06-21
I have a zip code coming in as character 9?  Is there a way in the Select SQL statement to change the zip code to numeric 5?
0
Comment
Question by:morinia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
didnthaveaname earned 500 total points
ID: 39266914
You could use:

select convert( numeric( 5, 0 ), left( zipColumn, 5 ) );

Open in new window

0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39266920
can you provide examples what you are getting what you need?
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39266938
>I have a zip code coming in as character 9?
Is this a question or a statement?  Mind readers we ain't.

>Is there a way in the Select SQL statement to change the zip code to numeric 5?
If you mean just insert the first five characters, and drop off the rest, then

SELECT LEFT(zip_code, 5)

If you mean something else, you'll need to give us details / sample data.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question