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 2000 Forums
 SQL Server Development (2000)
 2 decimalplaces

Author  Topic 

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-03-15 : 10:37:40
This is driving me mad. I have an asp.net web page with two textboxes where the user can enter figures that I want to appear with 2 decimal places eg 56.75, 45.50, 35.00

I have the fields inmy sql table as decimal, scale 2. I have also tried them as numeric and int to no avail.

Here's my sproc to which I have tried adding the ROUND function, it still saves the data as 56.00, 45.00 and 35.00

CREATE PROCEDURE spFOIA_UpdateRequest

@strFOIAID int,
@strAppTitle nvarchar(10),
@strAppInitials nvarchar(100),
@strAppFirstName nvarchar(100),
@strAppSurname nvarchar(100),
@strAdd1 nvarchar(100),
@strAdd2 nvarchar(100),
@strAdd3 nvarchar(100),
@strAdd4 nvarchar(100),
@strPostCode nvarchar(8),
@strDesc nvarchar(2000),
@strQryType nvarchar(100),
@strDateRecd datetime,
@strTargetDate datetime,
@strExempted nvarchar(1),
@strExemptedReason nvarchar(2000),
@strDateReply datetime,
@strDateReqCompleted datetime,
@strEMailAdd nvarchar(250),
@strLabCost int,
@strProdCost int

AS

BEGIN

UPDATE tblFOIARequest SET

FOIA_AppTitle =@strAppTitle,
FOIA_AppInitials=@strAppInitials,
FOIA_AppFirstName=@strAppFirstName,
FOIA_AppSurname=@strAppSurname,
FOIA_Add1=@strAdd1,
FOIA_Add2=@strAdd2,
FOIA_Add3=@strAdd3,
FOIA_Add4=@strAdd4 ,
FOIA_PostCode=@strPostCode,
FOIA_Desc=@strDesc ,
FOIA_QryType=@strQryType ,
FOIA_DateRecd=@strDateRecd,
FOIA_TargetDate=@strTargetDate,
FOIA_Exempted=@strExempted,
FOIA_ExemptedReason=@strExemptedReason,
FOIA_DateReply=@strDateReply,
FOIA_DateReqCompleted=@strDateReqCompleted,
FOIA_EMail=@strEMailAdd,
FOIA_LabCost=ROUND(@strLabCost,2),
FOIA_ProdCost=ROUND(@strProdCost,2)


WHERE FOIA_ID = @strFOIAID

END
GO


Please can someone help me.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-15 : 10:59:36
change
@strLabCost int,
@strProdCost int
to
@strLabCost decimal(12,2),
@strProdCost decimal(12,2)

and loose the round.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-03-15 : 11:05:00
and don't confuse displaying and formatting data, with how it is physically stored in your tables ...

- Jeff
Go to Top of Page
   

- Advertisement -