Convert a number to two decimal places in SQL Server Query
Many a times we get some number(float or double) from our sql query operation. But at the end we need a two decimal number. Then how can we achieve this
Solution 2: FORMAT(NumberorExpression,'##.##') Disadvantage here using this method 44.440 will be converted to 44.44 but 44.000 will be converted to 44 only. So when there is only zero after decimal then it simply returns the integer value.
Solution 1:
ReplyDeleteSELECT CONVERT(DECIMAL(10,2),Number)
Replace the number with the expression you want to change to two decimal
Solution 2:
ReplyDeleteFORMAT(NumberorExpression,'##.##')
Disadvantage here using this method 44.440 will be converted to 44.44 but 44.000 will be converted to 44 only.
So when there is only zero after decimal then it simply returns the integer value.