SQL/Answer Detail

How to round or truncate with no trailing zeros in sql server?

2 Points
1 Posts

I have following select command (round/truncate):

SELECT ROUND(100.55555552, 2)
SELECT ROUND(100.55555552, 2, 1)

Both giving trailing zeros

How we can remove trailing zeros?

Total Answered: 2
Total Marked As Answer: 0
Posted On: 23-Jan-2018 04:35
Share:   fb twitter linkedin
220 Points
90 Posts
Posted On: 25-Jan-2018 02:15

Use following:

SELECT convert(DOUBLE PRECISION, ROUND(100.55555552, 2))
SELECT convert(DOUBLE PRECISION, ROUND(100.55555552, 2, 1))
Rahul Maurya
1076 Points
208 Posts
Posted On: 25-Jan-2018 02:17

try this

SELECT CAST(ROUND(100.55555552, 2) AS DECIMAL(8,2))
SELECT CAST(ROUND(100.55555552, 2, 1) AS DECIMAL(8,2))


Active User (1)

 Log In to Chat