|
21 | 21 | -----
|
22 | 22 |
|
23 | 23 | ### Date and Time
|
24 |
| -| Data Type | Time Precision | Range | Storage | |
25 |
| -|-------------------|------------------------------------------------------------------------------------------|-------------------------------------------------------------|-----------| |
26 |
| -| date | None | Year 1 to 9999 | 3 Bytes | |
27 |
| -| datetime | To a 1/300th of a second (0.003) | Year 1753 to 9999 | 8 Bytes | |
28 |
| -| datetime2(n) | Up to 7 decimal places (0.0000001 seconds) | Year 1 to 9999 | 6-8 Bytes | |
29 |
| -| datetimeoffset(n) | Up to 7 decimal places (0.0000001 seconds), with offset between -12:59 to +14:00 | Year 1 to 9999 | 8-10 Bytes| |
30 |
| -| smalldatetime | To the nearest minute | Year 1900 to 2079 | 4 Bytes | |
31 |
| -| time(n) | Up to 7 decimal places (0.0000001 seconds) | None | 3-5 Bytes | |
| 24 | +| Data Type | Time Precision | Range | Storage | |
| 25 | +|-------------------|------------------------------------------------------------------------------------------|-------------------------------------------------------------|------------| |
| 26 | +| date | None | Year 1 to 9999 | 3 Bytes | |
| 27 | +| datetime | To a 1/300th of a second (0.003) | Year 1753 to 9999 | 8 Bytes | |
| 28 | +| datetime2(n) | Up to 7 decimal places (0.0000001 seconds) | Year 1 to 9999 | 6-8 Bytes | |
| 29 | +| datetimeoffset(n) | Up to 7 decimal places (0.0000001 seconds), with offset between -12:59 to +14:00 | Year 1 to 9999 | 8-10 Bytes | |
| 30 | +| smalldatetime | To the nearest minute | Year 1900 to 2079 | 4 Bytes | |
| 31 | +| time(n) | Up to 7 decimal places (0.0000001 seconds) | None | 3-5 Bytes | |
32 | 32 |
|
33 | 33 | -----
|
34 | 34 |
|
35 | 35 | ### Character Strings
|
36 | 36 |
|
37 |
| -| Data Type | Characters | Storage | Note | |
38 |
| -|--------------|-----------------------------------|---------------|-------------------------------| |
39 |
| -| char(n) | UTF-8; 1-8000 characters | n Bytes | | |
40 |
| -| varchar(n) | UTF-8; 1-8000 characters | Char+2 Bytes | | |
41 |
| -| text | UTF-8; 1-2,147,483,647 characters| Variable | Deprecated, use varchar | |
42 |
| -| varchar(max) | UTF-8; 1-2,147,483,647 characters| Variable | | |
| 37 | +| Data Type | Characters | Storage | Note | |
| 38 | +|--------------|-----------------------------------|--------------|-------------------------| |
| 39 | +| char(n) | UTF-8; 1-8000 characters | n Bytes | | |
| 40 | +| varchar(n) | UTF-8; 1-8000 characters | Char+2 Bytes | | |
| 41 | +| text | UTF-8; 1-2,147,483,647 characters | Variable | Deprecated, use varchar | |
| 42 | +| varchar(max) | UTF-8; 1-2,147,483,647 characters | Variable | | |
43 | 43 |
|
44 | 44 | -----
|
45 | 45 |
|
46 | 46 | ### Unicode Character Strings
|
47 | 47 |
|
48 |
| -| Data Type | Characters | Storage | Note | |
49 |
| -|--------------|-----------------------------------------|---------------|------------------------------| |
50 |
| -| nchar(n) | Unicode; 1-4000 characters | 2n Bytes | | |
51 |
| -| nvarchar(n) | Unicode; 1-4000 characters | 2Char+2 Bytes | | |
52 |
| -| ntext | Unicode; 1-1,073,741,823 characters | 2Char Bytes | Deprecated | |
53 |
| -| nvarchar(max)| Unicode; 1-1,073,741,823 characters | 2Char Bytes | | |
| 48 | +| Data Type | Characters | Storage | Note | |
| 49 | +|---------------|-----------------------------------------|---------------|------------------------------| |
| 50 | +| nchar(n) | Unicode; 1-4000 characters | 2n Bytes | | |
| 51 | +| nvarchar(n) | Unicode; 1-4000 characters | 2Char+2 Bytes | | |
| 52 | +| ntext | Unicode; 1-1,073,741,823 characters | 2Char Bytes | Deprecated | |
| 53 | +| nvarchar(max) | Unicode; 1-1,073,741,823 characters | 2Char Bytes | | |
54 | 54 |
|
55 | 55 | -----
|
56 | 56 |
|
57 | 57 | ### Binary Strings
|
58 |
| -| Data Type | Use When | |
59 |
| -|----------------|------------------------| |
60 |
| -| binary | Sizes are consistent | |
61 |
| -| varbinary | Sizes vary considerably| |
62 |
| -| varbinary(max) | More than 8000 bytes | |
| 58 | +| Data Type | Use When | |
| 59 | +|----------------|-------------------------| |
| 60 | +| binary | Sizes are consistent | |
| 61 | +| varbinary | Sizes vary considerably | |
| 62 | +| varbinary(max) | More than 8000 bytes | |
63 | 63 |
|
64 | 64 | -----
|
65 | 65 |
|
66 | 66 | ### Other Data Types
|
67 |
| -| Data Type | Note | |
68 |
| -|------------------|-------------------------------------------| |
69 |
| -| cursor | | |
70 |
| -| geography | | |
71 |
| -| geometry | | |
72 |
| -| hierarchyid | | |
73 |
| -| rowversion | | |
74 |
| -| sql_variant | | |
75 |
| -| table | | |
76 |
| -| uniqueidentifier | Unique value using NEWID or NEWSEQUENTIALID| |
77 |
| -| XML | | |
| 67 | +| Data Type | Note | |
| 68 | +|------------------|---------------------------------------------| |
| 69 | +| cursor | | |
| 70 | +| geography | | |
| 71 | +| geometry | | |
| 72 | +| hierarchyid | | |
| 73 | +| rowversion | | |
| 74 | +| sql_variant | | |
| 75 | +| table | | |
| 76 | +| uniqueidentifier | Unique value using NEWID or NEWSEQUENTIALID | |
| 77 | +| XML | | |
0 commit comments