Sql Server Data Types

SQL Server: Data Types

The following is a list of datatypes available in SQL Server (Transact-SQL), which includes string, numeric, and date/time datatypes.

String Datatypes

The following are the String Datatypes in SQL Server (Transact-SQL):

Data Type Syntax Explanation
CHAR(size) Where size is the number of characters to store. Fixed-length. Space padded on right to equal size characters. Non-Unicode data.
VARCHAR(size) or VARCHAR(max) Where size is the number of characters to store. Variable-length. If max is specified, the maximum number of characters is 2GB. Non-Unicode data.
TEXT Variable-length. Non-Unicode data.
NCHAR(size) Fixed-length. Unicode data.
NVARCHAR(size) or NVARCHAR(max) Where size is the number of characters to store. Variable-length. If max is specified, the maximum number of characters is 2GB. Unicode data.
NTEXT Variable length. Unicode data.
BINARY(size) Where size is the number of characters to store. Fixed-length. Space padded on right to equal size characters. Binary data.
VARBINARY(size) or VARBINARY(max) Where size is the number of characters to store. Variable-length. If max is specified, the maximum number of characters is 2GB. Non-Binary data.
IMAGE Variable length . Binary data.

Numeric Datatypes

The following are the Numeric Datatypes in SQL Server (Transact-SQL):

Data Type Syntax Explanation
BIT
TINYINT
SMALLINT
INT
BIGINT
DECIMAL(m,d) Where m is the total digits and d is the number of digits after the decimal.
DEC(m,d) Where m is the total digits and d is the number of digits after the decimal. This is a synonym for the DECIMAL datatype.
NUMERIC(m,d) Where m is the total digits and d is the number of digits after the decimal. This is a synonym for the DECIMAL datatype.
FLOAT(n) Where n is the number of number of bits to store in scientific notation.
REAL
SMALLMONEY
MONEY

Date/Time Datatypes

The following are the Date/Time Datatypes in SQL Server (Transact-SQL):

Data Type Syntax
DATE
DATETIME
DATETIME2(fractional seconds precision)
SMALLDATETIME
TIME
DATETIMEOFFSET(fractional seconds precision)