Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Decimal Places

Author  Topic 

steve_c
Yak Posting Veteran

54 Posts

Posted - 2008-02-07 : 07:59:27
Hi all, I have a stored proc which produces invoicelines for a report in SSRS. The 'unitprice' field is a decimal (19,3) this is because sometimes the unit price can be 0.005 (half a cent) - most of the time however, the unitprice is in a whole value. At the moment, the data comes out like so:

unitprice
0.005
1.500

Is there any way I can present the data properly if there is not a half cent present? Like this:

unitprice
0.005
1.50

I have tried to do it in the formatting of SSRS but can't work it out... Would be grateful for any help!

Thanks,

Stephen.

ayamas
Aged Yak Warrior

552 Posts

Posted - 2008-02-07 : 08:15:45
Try this
declare @num decimal(19,3)
set @num='0.005'
select cast(@num as real)
Go to Top of Page

steve_c
Yak Posting Veteran

54 Posts

Posted - 2008-02-07 : 14:21:07
Hi will try that tomorrow - so that would output 0.005 as 0.005 and 1.500 as 1.50?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-08 : 01:36:40
If you want to format in such a way in front end application, then use format function there
VB ex

Format(col,"######.###')

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -