Solved

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

Posted on 2013-06-21
3
448 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
3 Comments
 
LVL 8

Accepted Solution

by:
didnthaveaname earned 500 total points
Comment Utility
You could use:

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

Open in new window

0
 
LVL 16

Expert Comment

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

Expert Comment

by:Jim Horn
Comment Utility
>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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now