T-SQL Tutorial

Data Types - TSQL Tutorial

The Transact SQL language allow you to use various data types like: Numeric (int, numeric, decimal, float), Character Strings (char, varchar), Unicode Character Strings (nchar, nvarchar) , Date (date, datetime, datetime2, time) and other data types.

Binary Strings

  • Binary - fixed length binary data.
  • Varbinary - variable length binary data.
  • Image - store binary large object (BLOB).

Character Strings

  • Char - fixed size string data.
  • Varchar - variable size string data.
  • Text - store large amounts of text data.

Date and Time

  • Date - defines a date in SQL Server.
  • Datetime - defines a date with a time of day.
  • Datetime2 - extension of datetime type that has a larger date range.
  • Datetimeoffset - defines a date with a time of a day that has time zone awareness.
  • Smalldatetime - defines a date that is combined with a time of day.
  • Time - defines a time of a day.


  • Bigint - defines an integer data type with 8 bytes storage.
  • Int - the primary integer data type in SQL Server, has 4 bytes storage.
  • Smallint - defines an integer data type with 2 bytes storage.
  • Tinyint - defines an integer data type with 1 byte storage.
  • Decimal - defines a numeric data type with fixed precision and scale numbers.
  • Numeric - is functionally identical to decimal.
  • Bit - an integer data type that can take a value of 1, 0, or NULL.
  • Float - defines approximate numeric values.
  • Real - defines approximate numeric values with 4 bytes storage.
  • Money - represent monetary values.

Unicode Character Strings

  • Nchar - fixed size unicode string data.
  • Nvarchar - variable size unicode string data.
  • NText - store data such as text documents.

Other Data Types

  • Rowversion - exposes automatically generated, unique binary numbers.
  • Uniqueidentifier - is considered a character type for the purposes of conversion.
  • Table - store a result set for processing at a later time.
  • Cursor - defines an cursor data type for variables or stored procedure OUTPUT parameters.
  • SQL_VARIANT - stores values of various SQL Server.
  • XML - defines an xml data type.