Q
Get started Bring yourself up to speed with our introductory content.

Convert a numeric physical file to a character in SQL without leading zeros

In SQL, when converting a numeric physical file to digits, pass the results of the DIGITS function through the STRIP function in order to avoid leading zeros.

I have a physical file that is a numeric 11,0. When I convert this to digits, I get leading zeros. How can I convert this to a character in SQL and get rid of the leading zeros? If it's possible, I would like to convert it in the same field.
One solution is to pass the results of the DIGITS function through the STRIP function as I've shown here:
STRIP(DIGITS(numeric_field),L,'0')
That should solve your problem.
This was last published in June 2009

Dig Deeper on iSeries SQL commands and statements

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close