Reputation: 11
Using SQL, how do I convert a 5 digit zip code in integer format to a character format and still preserve the leading zero if there is one?
Upvotes: 0
Views: 302
Reputation: 3522
If you store a number as a number in SQL, it will always remove the leading zero. You are telling SQL that it's a number, and a number doesn't need leading zeros.
2 options are to:
1) Save it as a string and convert it to a number in your application
2) Save it as a number and format it with leading 0's in your application
Upvotes: 3