Free Web Development Online Tutorials, Learn to Code
Learn SQL Database Development, MS SQL Tutorial Online

SQL Data Types with Example

What is Data Type in SQL
Data Types in SQL is an attribute, which tells the type of data of any column, variable and expression has a related data type in SQL.

Here are the different data type examples in SQL Database

Strings Data Types in SQL Database

Data Type Example
char Max length of 8,000 characters (non-Unicode characters, fixed length)
varchar Max of 8,000 characters.(non-Unicode data, variable-length )
text Max length of 2,147,483,647 characters (variable length, non-Unicode data)
nchar Max length of 4,000 characters (unicode characters, fixed length)
nvarchar Max length of 4,000 characters (unicode characters, variable length)
ntext Max length of 1,073,741,823 characters. ( unicode, variable length)

Numeric Data Types in SQL Database

Data Type Example
bigint -+9,223,372,036,854,775,807
int -+2,147,483,648
numeric 10^38 -1
decimal 100000.000001
bit 0 or 1 (boolean)
money +- 922,337,203,685,477.5808
smallmoney +- 214,748.3648
Date Data Types in SQL Database
Data Type Example
datetime
smalldatetime
date
time
Binary Data Types in SQL Database
Data Type Example
binary Max length of 8,000 bytes(binary data, fixed length )
varbinary Max length of 8,000 bytes.(binary data, variable length)
image Max length of 2,147,483,647 bytes (binary data, variable length)
Misc Data Types in SQL Database
Data Type Example
uniqueidentifier Stores a GUID ( globally unique identifier )
xml Stores XML data.
timestamp unique number that gets updated every time a row gets updated
Comment
Name
Email
Website
Subscribe