SQL Data Types – Overview of Data Types in TSQL

All columns, variables or terms in SQL Server have their defined data types. These data types define of what type are the values which can be contained in given column or other logical object. Every time you try to create a table , variable or term, a definition defining sql data types is required.

Wrong data type selection in objects can later result in big troubles. Typical example is choice of data type for amount of sales for example. We wrongly select too short numeral format since we expect the company to never have higher sales than X USD. But we will be surprised when we get this Error “Arithmetic overflow error converting numeric to data type numeric” in a few years time.

SQL Data Type error

Except for its own data types in t-sql that can be defined in SQL Server using .NET framework, the SQL Server also provides default data types.

SQL Data types – Categories

System data types are in SQL Server into 7 logical categories:

Exact Numerics

  1. BIGINT
  2. BIT
  3. DECIMAL
  4. INT
  5. MONEY
  6. NUMERIC
  7. SMALLINT
  8. SMALLMONEY
  9. TINYINT

More details in this article – SQL Numeric Data Types – Big Overview

Approximate Numerics

  1. FLOAT
  2. REAL

Date and Time

  1. DATE
  2. DATETIME
  3. DATETIME2
  4. DATETIMEOFFSET
  5. SMALLDATETIME
  6. TIME

More details in this article – SQL DATE and TIME Data Types in SQL Server

Character strings + UNICODE

  1. CHAR + NCHAR
  2. VARCHAR + NVARCHAR
  3. TEXT + NTEXT

Binary strings

  1. BINARY
  2. VARBINARY
  3. IMAGE

Other data types

  1. CURSOR
  2. TIMESTAMP
  3. HIERARCHYID
  4. UNIQUEIDENTIFIER
  5. SQL_VARIANT
  6. XML
  7. TABLE
Rate this post
Category: SQL Tutorials

About Ing. Jan Zedníček - Data Engineer & Controlling

My name is Jan Zednicek, and I have been working as a freelance Data Engineer for roughly 10 years. During this time, I have been publishing case studies and technical guides on this website, targeting professionals, students, and enthusiasts interested in Data Engineering particularly on Microsoft technologies as well as corporate finance and reporting solutions. 🔥 If you found this article helpful, please share it or mention me on your website or Community forum

Leave a Reply

Your email address will not be published. Required fields are marked *