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 type rounding??? Help Newbie here

Author  Topic 

seanYsean
Starting Member

5 Posts

Posted - 2009-01-14 : 12:32:28
HI everyone, my name is Sean and I need some sql server 2005 data type help. I have a field in one of my tables that is collecting dollar and cent amounts. I set it up as a decimal(18, 2) but it rounds the decimal amount up when its insert into the table, ie.

24.57 -> insertion -> 25.00

I can trace all the way to the insertion and the .57 is there..so I know its sql server. Any help is greatly appreciated, thanks!

Sean

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-14 : 12:34:34
whats the datatype of table field? also are you applying ROUND() or doing any CAST() or CONVERT() in insert code.
Go to Top of Page

seanYsean
Starting Member

5 Posts

Posted - 2009-01-14 : 12:43:16
the datatype is just like I said above

decimal(18,2) and nothing wrapped around it on insert..

any ideas? thank you for the fast response!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-14 : 12:45:18
so select field from table gives you 25.00? or is it at your front end that you see this change?
Go to Top of Page

seanYsean
Starting Member

5 Posts

Posted - 2009-01-14 : 12:52:21
Its when the .net code inserts the value into the field it round the number. I can go in and put a decimal value in the field and on the page load it will show the value, but if I change the number to 25.89 it will put a 26 into the field on insertion. I have nothing wrapped around the field when I insert the record too..?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-14 : 12:56:43
that means its problem with your .net code snippet which does the insert.
Go to Top of Page

seanYsean
Starting Member

5 Posts

Posted - 2009-01-14 : 14:03:15
its a decimal variable I declared and populated it with the decimal value...then inserted....not sure what else to do??
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-14 : 23:03:11
check the .net insertion code
Go to Top of Page

seanYsean
Starting Member

5 Posts

Posted - 2009-01-16 : 12:52:49
did..not doing anything to the variable when inserting..
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-16 : 12:55:55
are you using LINQ or inline query or stored procedure?
Go to Top of Page
   

- Advertisement -