[thelist] MS SQL: Which data type to use?

Anthony Baratta anthony at baratta.com
Mon Jul 24 15:20:31 CDT 2006


You need to set the number of decimal places you want.

e.g. decimal(18, 0) is 18 slots before the decimal and none after the decimal.

Try decimal(18,4).

If you don't have them, get a copy of the SQL Online books. They are on the Tools CD or downloadable from MS. It's a 100 MB download, but worth it. Lot's of great information in there.

Like....

Numeric data types that have fixed precision and scale. 

decimal[ (p[ , s] )] and numeric[ (p[ , s] )] 
Fixed precision and scale numbers. When maximum precision is used, valid values are from - 10^38 +1 through 10^38 - 1. The SQL-92 synonyms for decimal are dec and dec(p, s). numeric is functionally equivalent to decimal.

p (precision) 
The maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision of 38. The default precision is 18.

s (scale) 
The maximum number of decimal digits that can be stored to the right of the decimal point. Scale must be a value from 0 through p. Scale can be specified only if precision is specified. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.


-----Original message-----
From: "Casey Crookston" caseyc at IntelliSoftmn.com
Date: Mon, 24 Jul 2006 12:59:14 -0700
To: thelist at lists.evolt.org
Subject: [thelist] MS SQL: Which data type to use?

> If I want to store numbers such as 0.025 in MS SQL, what data type
> should I be using.  I thought it would be Decimal, but that keeps
> rounding it up to Zero.




More information about the thelist mailing list