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
 General SQL Server Forums
 New to SQL Server Programming
 Decimal/smallmoney

Author  Topic 

stormcandi
Starting Member

46 Posts

Posted - 2007-04-27 : 13:35:24
Hello all,

I have two values (1.0 and 0.50 that need to be saved into SQL Server 2005 as numeric values. My issue is that when I try to save 0.5 to the table it is rounded up to 1.0. I checked the Stored Procedures and it looks good there. I tried the datatypes decimal (2, 1) and small money but both cause the value to round. Can anyone help me save the value as 0.5 to the table?

Thanks in advance!

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-27 : 13:44:54
We need to see some code, there's so many places things can be going wrong, it is impossible to guess.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

stormcandi
Starting Member

46 Posts

Posted - 2007-04-27 : 13:48:09
Here is the stored procedure that is updating the field. I have followed the code through to the SP and it still retains its 0.5 value. However it is during the update to the table that the value changes to 1.0.

@Term varchar(3),
@Year varchar(4),
@CName varchar(100),
@TID int,
@RecID int,
@Credit decimal
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

Update [Term 5 Courses]
Set
CName = @CName,
TID = @TID,
[yr/Term] = (@Year + @Term),
credit = @Credit
Where RecID = @RecID

END



if i go in the table and just type in 0.5 it does not round up.

Thanks for your assistance, Jeff.
Go to Top of Page

stormcandi
Starting Member

46 Posts

Posted - 2007-04-27 : 14:08:42
Ok Jeff,

I figured it out. When I pass in the @Credit decimal value I need to also state the length and #'s to the right of the decimla point. so I need to change the @Credit decimal to @Credit deimal(2, 1) in order for it to work correctly.

Thanks though for being here answering questions!

Candi
Go to Top of Page
   

- Advertisement -