It's an old post, but it was the first hit when I searched....
This is plain SQL, no extra functions needed:
select (case when floor(Amount) = Amount then 0 else len(round(reverse(Amount),0)) end) DecimalsAmount
try this:
select (case when floor(1.234) =1.234 then 0 else len(round(reverse(1.234),0)) end) Decimals_3
, (case when floor(5.0) =5.0 then 0 else len(round(reverse(5.0),0)) end) Decimals_0
The "reverse" puts everything behind the decimal in front.
This does not work when the decimal is a zero (1.0), that's why you need the floor as well.