Search code examples
sql-serversql-server-2017

SQL Server 2017 decimal rounding


I have used SQL Server 2005

SQL Server 2005 was:

select round(17.404800,2)

Result 17.40

select round(18.522400,2)

Result 18.52

but in SQL Server 2017 the results are:

select round(17.404800,2) 

Result 17.400000

select round(18.522400,2) 

Result 18.520000

I want to show SQL Server 2005 results ( = 17.40 / 18.52) in SQL Server 2017 - what should I do?


Solution

  • I think you should cast it

    like this -

    select  cast(round(18.522400,2) as decimal(6,2))
    

    Output -

    18.52