Ok... this takes 2 seconds longer (1,000,000 rows in 23 seconds instead of 21)... had to work around the "zero domain" on the LOG10 function to get this to work properly for whole numbers...
DECLARE @TestNum DECIMAL(38,15)
SET @TestNum = 99 --99.0000
SELECT CASE
WHEN FLOOR(REVERSE(ABS(@TestNum))) = 0.0
THEN 0
ELSE FLOOR(LOG10(REVERSE(ABS(@TestNum)))+1)
END
It does NOT support FLOAT... (the original problem description was based on the DECIMAL datatype so I think we're ok there)... Float does wierd things when you throw a REVERSE on it. If anyone needs a decimal place counter that works on FLOAT, we'll have to take a different tact...
--Jeff Moden
Change is inevitable... Change for the better is not.