Get the number of digits after the decimal point of a float (with or without decimal part)

前端 未结 6 1617
走了就别回头了
走了就别回头了 2020-12-18 16:45

I have following list of Amount (float) in my table.

Amount
123
123.1
123.0123
123.789456

How can i get the number of digits a

6条回答
  •  感动是毒
    2020-12-18 16:56

    This code will definitely help you.

    SELECT Amount,
           LEN(SUBSTRING(CAST(Amount as VARCHAR),CHARINDEX('.',CAST(Amount as VARCHAR))+1,LEN(Amount)))  Result
    FROM [Your Table Name]
    

提交回复
热议问题