Click here to Skip to main content
12,996,261 members (67,323 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 15 Oct 2004

Format Number to 2 Decimals in MS SQL without Rounding

, 15 Oct 2004
Rate this:
Please Sign up or sign in to vote.
Format any Number to 2 decimal Number without Rounding


If you wish to Format Number to 2 decimal without rounding off, here is the trick

Create Table in sql

 [area] [float] NULL


Insert Some data

INSERT INTO Table1 ([area]) VALUES(12.693)
INSERT INTO Table1 ([area]) VALUES(1256.12963)
INSERT INTO Table1 ([area]) VALUES(25.998596)
INSERT INTO Table1 ([area]) VALUES(1.963)


Now the query

cast(cast(area as int) as varchar(10)) + cast(substring(cast(area-cast(area as int) as varchar(10)),2,3) as varchar(4)),
FROM Table1


1) Convert number into integer

2) Subtract interger part from actual number 

3) Convert answer from step 2 to varchar and substring it to take 3 digits including decimal

4) Concate (+) step 1 and 2

Happy SQLing :)



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Canada Canada
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
Jaiprakash M Bankolli24-Oct-09 3:22
memberJaiprakash M Bankolli24-Oct-09 3:22 
GeneralDoesn't work for numbers without decimals that should be displayed with trailing .00 Pin
JaffarkKazi19-Oct-06 19:28
memberJaffarkKazi19-Oct-06 19:28 
QuestionWhy not use the floor command? Pin
Francisco Prata16-Oct-04 4:38
memberFrancisco Prata16-Oct-04 4:38 
AnswerRe: Why not use the floor command? Pin
Anonymous16-Oct-04 7:03
sussAnonymous16-Oct-04 7:03 
GeneralRe: Why not use the floor command? Pin
Francisco Prata16-Oct-04 8:00
memberFrancisco Prata16-Oct-04 8:00 
Questionwithout rouding off? Pin
Anonymous15-Oct-04 7:40
sussAnonymous15-Oct-04 7:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170609.2 | Last Updated 15 Oct 2004
Article Copyright 2004 by ashishnaik1
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid