Different INT data types
SQL Server supports 4 different integer value types such as INT, BIGINT, SMALLINT and TINYINT. The INT data type is the primary integer data type supported by SQL Server. When a database has large amount of data, the datatype really matters. So to save space it is best to use the smallest data type which should be sufficient to hold the values in the column. So for example to store a person’s age, the tinyint data type should be sufficient as the age value will be less than 200, and tinyint holds value between 0 to 255. But if we need to store values above 255 then, based on the largest possible value, the other data type should be used.
Below is the table of all INT data types and the range of values it will hold in the column.
Data Type |
Data Range |
Storage Size |
---|---|---|
INT |
-2,147,483,648 to 2,147,483,647 |
4 bytes |
BIGINT |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
8 bytes |
SMALLINT |
-32,768 to 32,767 |
2 bytes |
TINYINT |
0 to 255 |
1 byte |
Example of different INT data types used to create a table:
CREATE TABLE DemoINTValTable
(
DemoInt_Column INT,
,DemoBigInt_Column BIGINT,
DemoSmallInt_Column SMALLINT,
DemoTinyInt_Column TINYINT
);
GO
Below is the sample insert query with different INT values to the table:
INSERT INTO DemoINTValTable (
DemoInt_Column,
DemoBigInt_Column,
DemoSmallInt_Column,
DemoTinyInt_Column
)
VALUES
(
2147483647,
9223372036854775807,
32767,
255
);
SQL Server INT Data Type
In SQL Server, while creating a table column we give different data types to represent the type of values stored in the column. For numerical whole numbers, we give INT data type for a column in a table. In this article let us discuss the INT data type, how it is used, and the different INT data types available in SQL Server.
Contact Us