June 18, 2008 at 8:33 am
I have a strange problem: Stored procedure to feed a report.
The SP created a temp table and one of the fields is Decimal(8,1)
The sequence of building this field is:
Insert integer from a table
Update the field: this is a simple division formula, the result could be a decimal and I want it upto 1 place only:
Update #tempTable
Set theDecimalField = (12*IntegerField)/IntegerField
Where .... Just 1 condition
Final SP that puts all together is just a select * from #tempTable.
After verifying the math, one of the records should should give 1.6 in the DecimalField I get a 2.0 instead.
What am I missing?
June 18, 2008 at 3:12 pm
(IntegerConstant * IntegerColumn) / IntegerColumn = IntegerResult
You need to CONVERT or CAST somthing to at least Decimal(8, 2), then round. I'd suggest your IntegerConstant for this.
June 18, 2008 at 3:28 pm
Nah... make it easy on yourself...
(IntegerConstant * IntegerColumn *1.0) / IntegerColumn = IntegerResult
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply