How to extract zip codes with "0" in front

I'm really new to this, so if I write something that sounds weird, that's the reason!

I have a code that extracts address related items including zip codes. When it comes out, it can show 4 or 5 digits.

For instance:

I see the zip code for some city on the east coast as 9534.
Then in the list, I see the zip code for some city on the west coast like 98843.

However, my company likes to see the 9534 zip code as 09534. Just with the "0" showing up in front.

Now, I can just put it into Excel, highlight everything, format cell and hit special and then click on zip code, but I'd rather it come out of SQL with the 5 digits showing so I don't have to do that over and over again in Excel.

Here's just the basic select statement:

Select
street
, city
, state
, county
, zipcode
from (table name)

Is there anything I can add in that zipcode entry to get all 5 numbers, even if the first number is "0"?

Thanks!!!

, RIGHT('00' + zipcode, 5) AS zipcode

2 Likes

Thanks so much Scott!!! Took right off and did it!!!