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 Administration
 Decimal being rounded

Author  Topic 

davide128
Starting Member

2 Posts

Posted - 2010-05-05 : 10:39:15
Sorry..I'm new to SQL server 2008.
I have a table to a column that is set a data type of decimal.

data being inserted into that columns such as 50.625 is being rounded to 51..how do I prevent this?

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-05-05 : 10:46:18
You need to set a precision and scale to your decimal field.

Run these two. You will know the difference.
declare @d decimal
select @d = 50.625
select @d

declare @r decimal (10,3)
select @r = 50.625
select @r


Go to Top of Page

davide128
Starting Member

2 Posts

Posted - 2010-05-05 : 11:06:07
so if I set scale to 3 then numbers like 50 will get stored as 50.000?
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-05-05 : 11:07:24
Yes.
Go to Top of Page
   

- Advertisement -