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

Liam
Liam
2 Points
1 Posts

I have following select command (round/truncate):

--Round
SELECT ROUND(100.55555552, 2)
--Truncate
SELECT ROUND(100.55555552, 2, 1)

Both giving trailing zeros

How we can remove trailing zeros?

Views: 26063
Total Answered: 2
Total Marked As Answer: 1
Posted On: 23-Jan-2018 04:35

Share:   fb twitter linkedin
Answers
Smith
Smith
2890 Points
78 Posts
         

Use following:

--Round
SELECT convert(DOUBLE PRECISION, ROUND(100.55555552, 2))
--Truncate
SELECT convert(DOUBLE PRECISION, ROUND(100.55555552, 2, 1))
Posted On: 25-Jan-2018 02:15
Rahul Maurya
Rahul M...
4916 Points
27 Posts
         

try this

--Round
SELECT CAST(ROUND(100.55555552, 2) AS DECIMAL(8,2))
--Truncate
SELECT CAST(ROUND(100.55555552, 2, 1) AS DECIMAL(8,2))
Posted On: 25-Jan-2018 02:17
 Log In to Chat