Using Integer Data
Integers are whole numbers and do not contain decimals or fractions.
Microsoft SQL Server 2005 has the following sizes of integer data types:
Has a length of 8 bytes and stores numbers from –2^63 (-9,223,372,036,854,775,808) through 2^63-1 (9,223,372,036,854,775,807).
- integer or int
Has a length of 4 bytes, and stores numbers from -2,147,483,648 through 2,147,483,647.
Has a length of 2 bytes, and stores numbers from -32,768 through 32,767.
Has a length of 1 byte, and stores numbers from 0 through 255.
Integer objects and expressions can be used with any mathematical operations. Any fractions generated by these operations are truncated, not rounded. For example, SELECT 5/3 returns a value of 1, not the value 2, which would return if the fractional result were rounded.
The integer data types are the only ones that can be used with the IDENTITY property, which is an automatically incrementing number. The IDENTITY property is typically used to automatically generate unique identification numbers or primary keys.
Integer data does not need to be enclosed in single quotation marks like character or date and time data.