Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 How to remove trailing zeros from a decimal (type) value? Rate Topic Display Mode Topic Options
Author
 Message
 Posted Sunday, March 16, 2014 7:18 PM
 Valued Member Group: General Forum Members Last Login: Tuesday, November 11, 2014 2:31 PM Points: 59, Visits: 123
 Hi Everyone,I would like to 'drop' some trailing zeros from a decimal value, e.g.: 50.000000, and I am wondering how to go about this?The value is definitely of decimal type, and in this instance I know that I want to eliminate exactly six (6) zeros.Any help here will be greatly appreciated.Kind Regards,David
Post #1551618
 Posted Sunday, March 16, 2014 9:32 PM
 Old Hand Group: General Forum Members Last Login: Today @ 8:51 AM Points: 381, Visits: 1,645
 Normally you should not care about trailing 0's. The front end worries about the display and making it pretty.But if you have to, this should do it:`Select cast(100/2.0 as decimal(3))` __________________________________________________________________________________________________________How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1551629
 Posted Sunday, March 16, 2014 10:46 PM
 Valued Member Group: General Forum Members Last Login: Tuesday, November 11, 2014 2:31 PM Points: 59, Visits: 123
Post #1551634
 Posted Monday, March 17, 2014 5:39 AM
 SSCertifiable Group: General Forum Members Last Login: Yesterday @ 9:38 AM Points: 6,862, Visits: 14,160
 david.dartnell (3/16/2014)Hi Everyone,I would like to 'drop' some trailing zeros from a decimal value, e.g.: 50.000000, and I am wondering how to go about this?The value is definitely of decimal type, and in this instance I know that I want to eliminate exactly six (6) zeros.Any help here will be greatly appreciated.Kind Regards,DavidCast the value to whichever of the integer datatypes is appropriate. “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail ShawFor fast, accurate and documented assistance in answering your questions, please read this article.Understanding and using APPLY, (I) and (II) Paul White Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff ModenExploring Recursive CTEs by Example Dwain Camps
Post #1551692
 Posted Tuesday, March 18, 2014 11:55 PM
 Valued Member Group: General Forum Members Last Login: Tuesday, November 11, 2014 2:31 PM Points: 59, Visits: 123