1) SELECT round(0.144999999999, 2) GO Result: -------------- .140000000000 (1 row(s) affected) 2) SELECT round(round(0.144999999999, 3 ),2) go Result: -------------- .150000000000 (1 row(s) affected)Thanks.
Nope, that is expected behavior. SQL Server will retain all decimal places upon rounding off numbers. In the first case, you are rounding off .144 to two decimal places. The second 4 rounds down and the remainder of the digits are essentially turned into zeros. In the second case, you are rounding .1449 to three digits. This produces .145 which you then round to 2 places giving you .15 and the rest of the digits are zeroed out and retained. There should be a very technical discussion of rounding locted in books online that explains this in much more detail.
For More Information
- What do you think about this answer? E-mail us at editor@searchDatabase.com with your feedback.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- The Best SQL Web Links
- Have a SQL Server tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical SQL Server questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Microsoft SQL Server Installation
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.