Home  /  Questions  /  Question



128   96.7
Feb 23, 2013


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?



50   50
Sep 05, 2013
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