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. This is the topic of the following overview.
SQL Data types – Categories
System data types are in SQL Server into 7 logical categories:
- A) Exact Numerics
- BIGINT
- BIT
- DECIMAL
- INT
- MONEY
- NUMERIC
- SMALLINT
- SMALLMONEY
- TINYINT
More details in this article
- B) Approximate Numerics
- FLOAT
2.REAL
More details in this article
- C) Date and Time
- DATE
- DATETIME
- DATETIME2
- DATETIMEOFFSET
- SMALLDATETIME
- TIME
More details in this article
- D) Character strings + UNICODE
- CHAR + NCHAR
- VARCHAR + NVARCHAR
- TEXT + NTEXT
- E) Binary strings
- BINARY
- VARBINARY
- IMAGE
- F) Other data types
- CURSOR
- TIMESTAMP
- HIERARCHYID
- UNIQUEIDENTIFIER
- SQL_VARIANT
- XML
- TABLE
I will take a look at every category in a special article