views:

494

answers:

4

I have a table with two decimal(18,0) fields.

I am inserting into this table, two decimal values. For example, 1.11

When I select from the table (with no casts), I get 1.

I'm losing all percision and I have no clue why.

insert into TEST values (153, 'test', 'test', 1, 1, 1.11, 1.11)

Select * from TEST and they are 1 and 1 instead of 1.11,1.11

Any Ideas?

+5  A: 

When you declare a field as decimal(18,0), you are saying that you want 0 digits of precision after the decimal point. You're going to want to define those columns as decimal(18,2) (or however many digits of precision you desire) in order to maintain a value of 1.11.

Refer to the MSDN page on decimal and numeric types for the grisly details.

dpmattingly
A: 

Try changing to type decimal(9,2)

Spencer Ruport
A: 

Maybe try creating the columns as

decimal(18,2)

Bernhard Hofmann
A: 

Define the Precision to Decimal every time else it stores only int values not Decimal values

KuldipMCA