This function is about 100 times faster:
IF EXISTS (SELECT * FROM sysobjects WHERE name = N'DecimalPlaces')
DROP FUNCTION DecimalPlaces
GO
CREATE FUNCTION dbo.DecimalPlaces
(@A float)
RETURNS tinyint
AS
BEGIN
declare @r tinyint
IF @a IS NULL
RETURN NULL
set @r = 0
while @a - str(@A, 18 + @r, @r) <> 0
begin
end
RETURN @r
END
GO
_____________
Code for TallyGenerator