Search This Blog

Tuesday, January 21, 2014

Int, bigint, smallint, and tinyint SQL Server

SQL Server > Data Types > Int, bigint, smallint, and tinyint

These type are exact number data types and use integer data.
The bigint data type is used when integer values exceed the range.



bigint
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
int
-2,147,483,648 to 2,147,483,647
smallint
-32,768 to 32,767
tinyint
0 to 255
Example:

Use int type for primary key in a table

CREATE TABLE [dbo].[Table]
(
       [Id] INT NOT NULL PRIMARY KEY
)