Back to list
Views:   13.9K
Replies:  1

SQL Server: How do I truncate (not round) decimal places?

I am writing a stored procedure in SQL Server 2008 R2.
I am struggling with rounding / truncating a decimal value. 

For example the value 9.567 gets rounded up to 9.57, but that is not what I need.
In my situation I just need to truncate (chop off) the last digit. The desirable value is 9.56.

How do I do this?
Craig Johnston, Feb 23, 2013
Reply 1
select Convert(varchar,Floor(9.567))+'.'+Substring(Convert(varchar,9.567-Floor(9.567)),3,2)

You can create this as a function and call any where in the your stored procedure 
Yogesh Rajput, Sep 05, 2013

Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0