By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

getting rid of trailing zeroes from a decimal output

P: n/a
Hi
I use SqlServer 2000
I am doing a select and sending the results, which is a cast() into
decimal (9,3), in an email to various other users of our system.
Problem is that a number like 95.2 is display as 95.200. Is there any
way I can trim it so that it will display 95.2 ?
David

Jan 31 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
David Greenberg (da*****@iba.org.il) writes:
I use SqlServer 2000
I am doing a select and sending the results, which is a cast() into
decimal (9,3), in an email to various other users of our system.
Problem is that a number like 95.2 is display as 95.200. Is there any
way I can trim it so that it will display 95.2 ?


declare @val float
select @val = 9.2
select replace(
rtrim(
replace(
cast @val as decimal(9,3)),
'0', ' ')
),
' ', '0')
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Feb 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.