Solved

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

Posted on 2013-06-21
3
451 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
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSSQL Speen Degradation 4 23
SSIS I need to get the most old file from a folder in the SSIS package. 3 26
SQL Server tables join on parse list 6 24
SQL Error - Query 6 26
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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