codescracker


sql

SQL Data Types



« Previous Tutorial Next Tutorial »


Data type in SQL, is used to define, what type of value, a column can contain.

SQL Accurate Numeric Data Types

Here, the following table lists all the accurate numeric data types available in SQL:

Data 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
numeric -1038 +1 1038 -1
decimal -1038 +1 1038 -1
money -922,337,203,685,477.5808 +922,337,203,685,477.5807
smallmoney -214,748.3648 +214,748.3647

SQL Approximate Numeric Data Types

The table given below, lists the approximate numeric data types available in SQL:

Data Type From To
float -1.79E + 308 1.79E + 308
real -3.40E + 38 3.40E + 38

SQL Date and Time Data Types

The following table lists the date and time data type available in SQL:

Data Type From To
datetime Jan 1, 1753 Dec 31, 9999
smalldatetime Jan 1, 1900 Jun 6, 2079
date This data type stores a date like June 30, 1991 in SQL
time This data type stores a time of day like 12:30 P.M. in SQL

SQL Character Strings Data Types

The following table lists the character strings date types available in SQL:

Data Type Description
char Maximum length of 8,000 characters.( Fixed length non-Unicode characters)
varchar Maximum of 8,000 characters.(Variable-length non-Unicode data).
varchar(max) This data type is only for SQL Server 2005. Maximum length of 231 characters, Variable-length non-Unicode data
text Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters

Unicode Character Strings Data Types

Here is the table lists Unicode character strings data type available in SQL:

Data Type Description
nchar Maximum length of 4,000 characters (Fixed length Unicode)
nvarchar Maximum length of 4,000 characters (Variable length Unicode)
nvarchar(max) Maximum length of 231 characters, only for SQL Server 2005 (Variable length Unicode)
ntext Maximum length of 1,073,741,823 characters (Variable length Unicode)

Binary Data Types

Here is the table lists binary data types available in SQL:

Data Type Description
binary Maximum length of 8,000 bytes (Fixed-length binary data)
varbinary Maximum length of 8,000 bytes (Variable length binary data)
varbinary(max) Maximum length of 231 bytes, only for SQL Server 2005 (Variable length Binary data)
image Maximum length of 2,147,483,647 bytes (Variable length Binary Data)

« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test