Sql server tutorials

Updated : Sep 18, 2019 in SQL server

SQL Server Data Types

in this article, we will discuss the SQL Server Data Types and basic syntaxes

Data types column defines what value the column can hold like integer, date and time, money, character, binary, and etc. and this data types column holds specify type only and type-safe

What is Data Type in SQL?

Each column in a SQL table should have a name and a data type.

SQL Server has a different of data types, In a Database table, You have to decide what type of data you are going to be kept within every and each table column

The data type is a helper for the SQL server to understand what type of data is expected inside of column, and  SQL will interact with the stored data.

SQL Server Data Types

SQL data types can be classified into the following types

  • Numeric data types:   int, tinyint, bigint, float, real, etc.
  • Date and Time:   Date, Time, Datetime, etc.
  • Character and String: char, varchar, text, etc.
  • Unicode character string:  , nvarchar, ntext, etc.
  • Binary data:  binary, varbinary, etc.
  • Miscellaneous data Types: clob, blob, xml, cursor, table, etc.

SQL Numeric Data Types

decimal-10^38 +110^38 -1
numeric-10^38 +110^38 -1
real-3.40E + 383.40E + 38
float-1.79E + 3081.79E + 308

SQL Date and Time Data Types

DATEstores data information format YYYY-MM-DD
TIMEstores data information format HH:MI:SS
DATETIMEStores date and time format YYYY-MM-DD HH:MI:SS
TIMESTAMPstores data information format (‘1970-01-01 00:00:00’ UTC)
YEARStores year in 2 digits or 4 digit format. Range 1901 to 2155 in 4-digit format. Range 70 to 69, representing 1970 to 2069.

SQL Character and String Data Types

CHARa maximum length of 8,000 characters
VARCHARa maximum length of 8,000 characters
VARCHAR(max)Variable-length storage with provided max characters, not supported in MySQL
TEXTmaximum size of 2GB data

SQL Unicode Character and String Data Types

NCHARa maximum length of 4,000 characters
NVARCHARa maximum length of 4,000 characters
NVARCHAR(max)storage with provided max characters
NTEXTmaximum size of 1GB data

SQL Binary Data Types

BINARYa maximum length of 8,000 bytes
VARBINARYa maximum length of 8,000 bytes
VARBINARY(max)Variable-length storage with provided max bytes
IMAGEmaximum size of 2GB binary data

SQL Other Data Types

CLOBIt that can hold up to 2GB
BLOBFor binary large objects
XMLfor storing XML data
JSONfor storing JSON data

Also see the Link Cursor in SQL Server with example

Latest posts by DuttaluruVijayakumar (see all)
Like Love Haha Wow Sad Angry

Newest Most Voted
Inline Feedbacks
View all comments
Free Stuff
January 28, 2020 10:15 pm

Hello my friend! I wish to say that this post is awesome, nice written and include almost all significant infos. I would like to look extra posts like this .

Hairstyles Women
February 12, 2020 5:58 am

Oh my goodness! an amazing article dude. Thank you

March 13, 2020 4:45 pm

One of our guests recently suggested the following website.