>> A better idea is to use the correct datatype. ,<<
I agree with that statement. In fact read his posted this in a wonderful single principal, for which a given great credit. It is that store data the way it is used and use data the way it is stored. I wish I had said that
>> If the column is supposed to only handle digits, then changing the datatype of the column to be an INTEGER would eliminate the need for such checks and may save some disk and memory space in the process. <<
I'm sorry but did you mean "if the column is supposed to currently accept only digits", so we have no flexibility for alphanumeric's, punctuation or complete replacement some elaborate scheme of parsing the encoding?
I always keep a copy of an old book from 1836, "the North American arithmetic part the third for the advanced scholar," which you can download on project Gutenberg. It's just a fun read to see how things changed over the decades, but at the start of it. It defines numbers as representing quantities or magnitudes. We didn't have information theory or encoding scheme theory (actually started in 1947!), So what you're doing is fundamentally wrong
Back in the 1950s and maybe the early 1960s, storage was still insanely expensive. One of my favorite little memes is a picture of a forklift taking a disk drive of a cargo plane next to someone holding an older memory stick has more storage capacity than the huge physical IBM disk drive. Memory and storage are cheap. Access methods are insanely fast. It is very rare that you have to optimize the physical storage in the 21st century.
>> If the column needs to contain something fixed width with leading zeros, do that at display time instead of storing it that way. <<
What do those leading zeros have meaning? For example, leading zeros in the US postal systems ZIP Code indicate a particular geographic quadrant of the United States. Now I can try assure thar every program written from now until the end of the system, no to properly pad every ZIP Code every time. Over and over thousands, hundreds of thousands of times, millions of times whenever they see a three or four digit integer before they have converted it to a string.
And then when I pass my ZIP Code information to a second product or application, I'll have to guarantee that they also follow this conversion.
This is even weirder with remember that the ZIP Code is five characters, but an integer is usually eight characters (eight bytes) .
While I have not done the research, my observation has been that in ISO encoding schemes. The vast majority are significantly less than 16 characters long (look at your credit card numbers) and that most are five or fewer digits in length. In short, the use of integers in the real world for things that are by their very nature, character strings and identifiers actually cost storage, as well as making the program a hell of a lot harder.
Please post DDL and follow ANSI/ISO standards when asking for help.