[Webinar] Streamline your web hosting managementRegister Today

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

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

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
morinia
Asked:
morinia
1 Solution
 
didnthaveanameCommented:
You could use:

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

Open in new window

0
 
Surendra NathTechnology LeadCommented:
can you provide examples what you are getting what you need?
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

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