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 in MSSQL SERVER

Author  Topic 

PrabhatM
Starting Member

6 Posts

Posted - 2010-09-10 : 10:23:55
Hi,

I have set a field property as decimal(18,2).

But whenever I update a value like 2.40, it stores and returns 2.00 and 3.00 when I try 2.5

Please help.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-09-10 : 12:19:26
Seems to work for me. Are you using a DECIMAL variable that you did not specify the precision and scale for? Becasue if you didn't the default is a scale of zero, which acts like a int/bigint.
DECLARE @T TABLE(Val DECIMAL(18,2))

INSERT @T VALUES (2.4), (2.5), (3.0), (99.888)

-- Works
SELECT *
FROM @T


-- No scale specified "issue"...
DECLARE @Foo DECIMAL
SET @Foo = CAST(99.87 AS DECIMAL(18,2))

SELECT @Foo
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-13 : 05:46:49
How are you inserting data to the column?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -