• 13. 1. 2020
  • Ing. Jan Zedníček - Data Engineer & Controlling
  • 0

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

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

My name is Jan Zedníček and I have been working as a freelancer for many companies for more than 10 years. I used to work as a financial controller, analyst and manager at many different companies in field of banking and manufacturing. When I am not at work, I like playing volleyball, chess, doing a workout in the gym.

🔥 If you found this article helpful, please share it or mention me on your website

Leave a Reply

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