SQL DataTypes

SQL Data Type defines the type of Data that is going to be stored in a column. Most of the RDBMS will define use their own datatypes. So You may not find all datatypes of Ms SQL server in MySQL or ViceVersa. 

SQL Server provides a large number of data types that allows further data manipulation. There are four main groups:

1. Numbers:

Type

From

To

bigint

-9,223,372,036,854,775,808

9,223,372,036,854,775,807

int

-2,147,483,648

2,147,483,647

smallint

-32,768

32,767

tinyint

0

255

bit

0

1

decimal

-1038 +1

1038 –1

numeric

-1038 +1

1038 –1

money

-922,337,203,685,477.5808

+922,337,203,685,477.5807

smallmoney

-214,748.3648

+214,748.3647

2. Date:

Type

From

To

Datetime

Jan 1, 1753

Dec 31, 9999

smalldatetime

Jan 1, 1900

Jun 6, 2079

3. Characters:

Type

Description

char

Fixed-length non-Unicode character data with a maximum length of 8,000 characters.

varchar

Variable-length non-Unicode data with a maximum of 8,000 characters.

text

Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters.

nchar

Fixed-length Unicode data with a maximum length of 4,000 characters. Wide characters support ( e.g. Chinese, Arabic, etc)  

nvarchar

Variable-length Unicode data with a maximum length of 4,000 characters. ( e.g. Chinese, Arabic, etc)

ntext

Variable-length Unicode data with a maximum length of 1,073,741,823 characters. ( e.g. Chinese, Arabic, etc)

4. Binary:

Type

Description

binary

Fixed-length binary data with a maximum length of 8,000 bytes.

varbinary

Variable-length binary data. Maximum length 8,000 bytes.

image

Variable-length binary data. Maximum length 2,147,483,647 bytes.