Numeric Data

Creating and Maintaining Databases

Creating and Maintaining Databases

Numeric Data

Numeric data consists of numbers only. Numeric data includes positive and negative numbers, decimal and fractional numbers, and whole numbers (integers).

Integer Data

Integer data consists of negative or positive whole numbers, such as -15, 0, 5, and 2509. Integer data is stored using the bigint, int, smallint, and tinyint data types in Microsoft® SQL Server™ 2000. The bigint data type can store a larger range of numbers than the int data type. The int data type can store a larger range of integers than smallint, which can store a larger range of numbers than tinyint.

Use the bigint data type to store numbers in the range from -2^63 (-9223372036854775808) through 2^63-1 (9223372036854775807). Storage size is 8 bytes.

Use the int data type to store numbers in the range from -2,147,483,648 through 2,147,483,647 only (requires 4 bytes of storage per value).

Use the smallint data type to store numbers in the range from -32,768 through 32,767 only (requires 2 bytes of storage per value), and the tinyint data type to store numbers in the range from 0 through 255 only (requires 1 byte of storage per value).

Decimal Data

Decimal data consists of data that is stored to the least significant digit. Decimal data is stored using decimal or numeric data types in SQL Server. The number of bytes required to store a decimal or numeric value depends on the total number of digits for the data and the number of decimal digits to the right of the decimal point. For example, more bytes are required to store the value 19283.29383 than to store the value 1.1.

In SQL Server, the numeric data type is equivalent to the decimal data type.

Approximate Numeric Data

Approximate numeric (floating-point) data consists of data preserved as accurately as the binary numbering system can offer. Approximate numeric data is stored using the float and real data types in SQL Server. For example, because the fraction one-third in decimal notation is .333333 (repeating), this value cannot be represented precisely using approximate decimal data. Therefore, the value retrieved from SQL Server may not be exactly what was stored originally in the column. Additional examples of numeric approximations are floating-point values ending in .3, .6, and .7.

See Also

decimal and numeric

float and real

int, bigint, smallint, and tinyint

Using Data Types

Using decimal, float, and real Data

Using Integer Data