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.
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
- BIGINT
- BIT
- DECIMAL
- INT
- MONEY
- NUMERIC
- SMALLINT
- SMALLMONEY
- TINYINT
More details in this article – SQL Numeric Data Types – Big Overview
Approximate Numerics
- FLOAT
- REAL
Date and Time
- DATE
- DATETIME
- DATETIME2
- DATETIMEOFFSET
- SMALLDATETIME
- TIME
More details in this article – SQL DATE and TIME Data Types in SQL Server
Character strings + UNICODE
- CHAR + NCHAR
- VARCHAR + NVARCHAR
- TEXT + NTEXT
Binary strings
- BINARY
- VARBINARY
- IMAGE
Other data types
- CURSOR
- TIMESTAMP
- HIERARCHYID
- UNIQUEIDENTIFIER
- SQL_VARIANT
- XML
- TABLE