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. |
... ... |
|
|
|
|