Data types in SQL Server

Below are the data types (data types) in SQL Server, including character strings, numbers and times / dates.

Character string data type in SQL Server

Below are the types of character string data in SQL Server (Transact-SQL).

Data type syntax Maximum size Explanation CHAR (kich_thuoc) Maximum of 8000 characters.
  1. kich_thuoc is the number of characters stored.
  2. Fixed length.
  3. Add a space to the right to offset the space for enough characters.
  4. Does not contain Unicode characters.
VARCHAR (kich_thuoc) or VARCHAR (toi_da) Maximum of 8000 characters or maximum number.
  1. kich_thuoc is the number of characters stored.
  2. Custom length.
  3. If specified as toi_da, the maximum is 2GB.
  4. Does not contain Unicode characters.
TEXT Max 2GB.
  1. Custom length.
  2. Does not contain Unicode characters.
NCHAR (kich_thuoc) Maximum of 4000 characters.
  1. Fixed length.
  2. Unicode character.
NVARCHAR (kich_thuoc) or NVARCHAR (toi_da) Maximum of 4000 characters or maximum number.
  1. kich_thuoc is the number of characters stored.
  2. Custom length.
  3. If the number toi_da is specified, the maximum number of characters is 2GB.
  4. Unicode character.
NTEXT Maximum 1,073,741,823 bytes.
  1. Custom length.
  2. Unicode character.
BINARY (kich_thuoc) Maximum of 8000 characters.
  1. kich_thuoc is the number of characters stored.
  2. Fixed length.
  3. Add a space to compensate the space for enough characters.
  4. Binary data.
VARBINARY (kich_thuoc) or VARBINARY (toi_da) Maximum of 8000 characters or maximum number.
  1. kich_thuoc is the number of characters stored.
  2. Custom length.
  3. If specified as toi_da, the maximum is 2GB.
  4. Binary data.
IMAGE maximum size is 2GB.
  1. Custom length.
  2. Binary data.

Data type in SQL

Digital data type in SQL Server

Below is a list of numeric data types in SQL Server (Transact-SQL).

Syntax of data type Maximum size Explain BIT integers 0, 1 or NULL TINYINT from 0 to 255 SMALLINT from -32768 to 32767 INT -2,147,483,648 to 2,147,483,647 BIGINT from -9,223,372,036,854,775,808 to 9,223,372,036,808,80,807 DECIMAL (m, d)
  1. The default m is 18 if not specified.
  2. d default is 0 if not specified.
m is the total number of numbers and d is the number of numbers after the comma. DEC (m, d)
  1. The default m is 18 if not specified.
  2. d default is 0 if not specified.

m is the total number of numbers and d is the number of numbers after the comma.

Synonym with DECIMAL data type.

NUMERIC (m, d)
  1. The default m is 18 if not specified.
  2. d default is 0 if not specified.

m is the total number of numbers and d is the number of numbers after the comma.

Synonym with DECIMAL data type.

FLOAT (n) number of commas n is defaulted to 53 if not specified. n is the number of bits stored in a chemical symbol. REAL is equivalent to FLOAT (24) SMALLMONEY from - 214,748.3648 to 214,748.3647 MONEY from -922,337,203,685,477,5808 to 922,337,203,685,477,5807

Date / time data type in SQL Server

Below is a list of date / time data types in SQL Server (Transact-SQL).

Syntax of data type Maximum size Explain DATE value from '0001-01-01' to '9999-12-31. displayed as 'YYYY-MM-DD' DATETIME
  1. Date taken from '1753-01-01 00:00:00' to '9999-12-31 23:59:59'.
  2. Hours are taken from '00: 00: 00' to '23: 59: 59: 997'
displayed as' YYYY-MM-DD hh: mm: ss [.mmm] DATETIME2 (accurate to the decimal number of seconds)
  1. value taken from '0001-01-01' to '9999-12-31'.
  2. Time taken from '00: 00: 00 'to' 23: 59: 59: 9999999 '.
displayed as 'YYYY-MM-DD hh: mm: ss [. decimal seconds]' SMALLDATETIME
  1. The value is from '1900-01-01' to '2079-06-06'.
  2. Time taken from '00: 00: 00 'to' 23: 59: 59 '.
displayed as' YYYY-MM-DD hh: mm: ss TIME
  1. The value is from '00: 00: 00.0000000 'to' 23: 59: 59.9999999 '.
  2. Date taken from '0001-01-01' to '9999-12-31'.
displayed as 'YYYY-MM-DD hh: mm: ss [.nnnnnnn]' DATETIMEOFFSET (accurate to decimal number of seconds)
  1. time value taken from '00: 00: 00 'to' 23: 59: 59: 9999999 '.
  2. Time zone taken from -14: 00 to +14: 00.
displayed as YYYY-MM-DD hh: mm: ss [.nnnnnnn] '[{+ | -} hh: mm]

Previous article: PIVOT clause in SQL Server

The following article: CREATE TABLE command in SQL Server

4.5 ★ | 2 Vote

May be interested

  • HOW TO INSTALL ISA SERVER ENTERPRISE 2000 - Part IIHOW TO INSTALL ISA SERVER ENTERPRISE 2000 - Part II
    one of the most important parts on isa server systems is to understand exactly what services are running on isa server, how these services work together, and with what types of isa clients. a simple diagram can be sketched as follows about the main services running on the isa server.
  • Encryption in SQL Server 2005Encryption in SQL Server 2005
    encryption is an important method of data security. sensitive data such as cmt numbers, credit card numbers, passwords ... need to be protected against numerous current threats. in sql server 2000 you can create your own functions or use external dlls to encrypt data. in sql server 2005, functions and methods
  • SQL Server 2005 - Next generation data analysis and management softwareSQL Server 2005 - Next generation data analysis and management software
    today, organizations are always faced with data difficulties: the development of data and systems in business operations; it is necessary to provide employees, customers and partners with access to data in a timely manner
  • What is the future of server virtualization?What is the future of server virtualization?
    server virtualization can help combat poor server performance, make better use of computing capabilities, limit energy consumption and improve data center flexibility.
  • How to create a copy of data in MS SQL ServerHow to create a copy of data in MS SQL Server
    this is the guide to create backup for database in ms sql server.
  • Create VPN Server on Windows 8Create VPN Server on Windows 8
    no need to install any additional applications, you can easily 'turn' your computer into a vpn server if you're using windows 8. in this way, you can share data from the computer. as a simple lan system in the form of remote access. & a
  • C ++ exercises have solutions (sample code) for variables, data types, and operatorsC ++ exercises have solutions (sample code) for variables, data types, and operators
    in the previous c ++ exercises, tipsmake.com introduced, you were acquainted with many types of lessons, from simple to complex. in this c ++ exercise, we will become familiar with c ++ exercises on variables and data types in c ++.
  • What types of data are for sale on the dark web?What types of data are for sale on the dark web?
    what are the most popular types of data for sale on the dark web?
  • The difference between web server and app serverThe difference between web server and app server
    you have probably seen that the terms web server and app server are often used interchangeably as if they are related to the same thing and also facilitate the website to function properly. but in reality, they are not the same.
  • How to set up your own email server on Windows PCHow to set up your own email server on Windows PC
    today, almost all popular web-mail providers, including gmail, yahoo and outlook, regularly scan users' email, which is big data. so should lovers and privacy promotion surrender to the power of big data companies?