Organizing SQL Server data types

Source: Internet
Author: User

In the normal development process, in the design of data, often encountered the problem of data type selection, in order to faster, more appropriate to choose the correct data type, so here is a summary.

Classification SQL Server
Data type
C#
Data type
Describe Application Scenarios
Characters and strings CHAR (n) String Fixed-length string with a maximum of 8,000 characters
NCHAR (n) String Fixed-length Unicode data with a maximum of 4,000 characters
VARCHAR (n) String Variable-length string with a maximum of 8,000 characters "Common", which represents a string and does not contain Chinese.
nvarchar (n) String Variable-length Unicode data with a maximum of 4,000 characters "Common", which represents a string that contains Chinese.
varchar (max) String Variable-length string with a maximum of 1,073,741,824 characters "Common", with varchar (n), stores more characters.
nvarchar (max) String Variable-length Unicode data with a maximum of 536,870,912 characters "Common", with nvarchar (n), stores more characters.
Text String Variable-length string, up to 2GB
ntext String Variable-length UNICDE data, up to 2GB
Integer Bit bool Represents 0,1 or null A field that is typically used to indicate whether or not two states are in use.
tinyint Byte An integer representing the 0~255 range Commonly used to represent states or types, and in C # you can define enumerations to represent them.
smallint Short An integer representing the range -2^15 to 2^15-1
Int Int An integer representing the range -2^31 to 2^31-1 "Common", representing integers, or self-increasing primary key IDs
bigint Long An integer representing the range -2^63 to 2^63-1 "Common", which represents integers, represents a larger range.
Exact number Float Single Represents a 32-bit floating point number with a precision of 7 bits Common, the initialization suffix uses F or F, which is generally used to denote the amount.
Double Double Represents a 64-bit floating point number with a precision of 15 to 16 bits "Common", initialize suffix using D or D
Decimal Decimal Represents a 128-bit floating point number with a precision of 28 to 29 bits Initialize suffix using m or m
Currency SmallMoney Decimal Ditto
Money Decimal Ditto
Date Time smalldatetime Datetime Represents a precision of 1 minutes from January 1, 1900 to June 6, 2079.
Datetime Datetime From January 1, 1753 to December 31, 9999, the accuracy is 100 nanoseconds. "Common", which represents time.
Binary Binary Byte[] Represents fixed-length binary data with a maximum of 8,000 characters
varbinary (n) Byte[] Represents a variable-length binary data that stores up to 8,000 characters
varbinary (max) Byte[] Represents variable-length binary data with up to 2GB of storage "Common", typically used to store compressed data.
Image Byte[] Represents variable-length binary data with up to 2GB of storage
Mark Timestamp N/A Timestamp, the data type is unique in every table! When one record in the table changes, the timestamp field of the record is automatically updated
uniqueidentifier Guid Store Global Identifiers (GUIDs) Commonly used to represent a primary key, a unique identifier.
... ...

Transferred from: http://www.cnblogs.com/mcgrady/p/5776255.html

Organizing SQL Server data types

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.