Alex
Alex

Reputation: 44719

How to round with no trailing zeros in SQL Server 2005?

How to round with no trailing zeros in SQL Server 2005?

    select round(100.5555, 2)

...yields 100.5500. How to get rid of the zeros?

Upvotes: 11

Views: 27904

Answers (3)

Robin Day
Robin Day

Reputation: 102478

You could re-cast it as your original datatype, e.g.

SELECT CAST(ROUND(100.5555, 2) AS FLOAT)

However, this sounds like display logic and therefore, I suspect you are better off doing this within your UI rather than your DB.

Upvotes: 9

Adriaan Stander
Adriaan Stander

Reputation: 166396

Try this

select CAST(round(100.5555, 2) AS DECIMAL(8,2))

Upvotes: 17

Saar
Saar

Reputation: 8474

declare @d decimal(8,2) can help you.

Upvotes: 1

Related Questions