Skip to main content
Inspiring
June 19, 2008
Question

sql server 2000 data type

  • June 19, 2008
  • 3 replies
  • 862 views
In sql server 2000, what data type do I use for a field that needs to show two decimal places? It is a weight field, so the weight in ounces could be something like 12.25 and it needs to store it this way in the database. I'm kind of new to sql server, so any help would be greatly appreciated!
This topic has been closed for replies.

3 replies

Participating Frequently
June 19, 2008
You asked "In sql server 2000, what data type do I use for a field that needs to show two decimal places?" and I answered "decimal and numeric". How much clearer could I be?

Numeric data types with 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).

p (precision)

Specifies 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. The maximum precision is 38.

s (scale)

Specifies 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. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.


I recommend that you load SQL Server Books Online on your computer, as it is available free from Microsoft as a download and it has everything you will probably need to know about SQL Server. Or you could just use the online version at SQL Server 2000 Books Online

Phil
ssailerAuthor
Inspiring
June 19, 2008
I'm not sure if I understand what you're saying. Are you saying, that in the table, I should assign the field a decimal Data Type? Sorry - not sure what you're suggesting.
Participating Frequently
June 19, 2008
decimal and numeric
decimal
Fixed precision and scale numeric data from -10^38 +1 through 10^38 –1.

numeric
Functionally equivalent to decimal

Phil