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

Liam
Liam
Member
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: 25303
Total Answered: 2
Total Marked As Answer: 1
Posted On: 23-Jan-2018 04:35

Share:   fb twitter linkedin
Answers
Smith
Smith
None
2568 Points
74 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...
Teacher
4822 Points
23 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