DIGITS returns a character string representation of a number with leading zeros. The length of the character string depends on the data type of the number.
Small Integer returns a CHAR 5
Large Integer returns a CHAR 10
Big Integer returns a CHAR 19
Decimal returns a CHAR x where X is the Precision of the Decimal.
There isn't an exact equivalent in SQL. The closest single function is STR whose format is STR(value, length).
If you have a Smallint value of 29 you would use STR(29,5).
This will return a right justified number WITHOUT leading zeros.
Code:
DIGITS: 00029
STR: 29
If you can not work without leading zeros, you will need to do more work to add them.