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

Casey Crookston caseyc at IntelliSoftmn.com
Mon Jul 24 15:54:20 CDT 2006

```Anthony,

Thank you for such an in-depth answer.  Problem solved.

Casey

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Anthony Baratta
Sent: Monday, July 24, 2006 3:21 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] MS SQL: Which data type to use?

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
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.

--

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !

```