SQL Data Types:
In this post, we see SQL Data Types in detail.
In SQL Server, each column in a database table has a name and a data type. We need to decide what type of data to store inside each and every column of a table while creating a SQL table.
SQL Server supplies a set of system data types that define all types of data that can be used with the SQL Server.
SQL Server offers following categories of data types:
Let’s see the SQL Data Types in detail.
bigint = Range from -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
int = Range from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)
smallint = Range from -2^15 (-32,768) to 2^15-1 (32,767)
tinyint = Range from 0 to 255
bit = 0 and 1
decimal = Range from –10^38 +1 to 10^38 -1
numeric = Range from -10^38 +1 to 10^38 -1
money = Range from -922,337,203,685,477.5808 to +922,337,203,685,477.5807
small money = Range from -214,748.3648 to +214,748.3647
float = Range from -1.79E + 308 to 1.79E + 308
real = Range from -3.40E + 38 to 3.40E + 38
datetime = From Jan 1, 1753 to Dec 31, 9999
smalldatetime = From Jan 1, 1900 to Jun 6, 2079
date = To store a date like March 27, 1986
time = To store a time of day like 12:00 A.M.
char = Maximum length of 8,000 characters
varchar = Maximum of 8,000 characters
varchar(max) = Maximum length of 231 characters
text = Maximum length of 2,147,483,647 characters.
nchar = Maximum length of 4,000 characters
nvarchar = Maximum length of 4,000 characters
nvarchar(max) = Maximum length of 231 characters
ntext = Maximum length of 1,073,741,823 characters
binary = Maximum length of 8,000 bytes
varbinary = Maximum length of 8,000 bytes
varbinary(max) = Maximum length of 231 bytes
image = Maximum length of 2,147,483,647 bytes
In the next tutorial, we will see Operators In SQL
Check out the complete SQL Tutorial by clicking on below link: