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 after the decimal point.
Duplicate ?: I have checked already existing posts, but there is no correct way to handle the float
numbers with or without decimal part
.
Result
Amount Result
123 0
123.1 1
123.0123 4
123.789456 6
EDIT : After spending some valuable time, i have found some relatively simple script to handle this. My answer is below
Since this was said to be a duplicate of this question - SQL Server how to get money type's decimal digits? - I have no choice to put my answer here.
Abdul Thanks for pointing my mistake. I was not aware of peculiar behaviour of float.
Here see this line will do the trick,
Complete script,
You can do It in following:
QUERY
OUPUT
And one more way:
Output:
I found some simple script (relatively to me) to handle this.
Here the
ISNULL(NULLIF
is only to handle the float without decimal part. If there is no values without decimal part, then it is very simpleHope this will be helpful to you. Full script below
This code will definitely help you.