May 19, 2016

T-SQL Data type

Data type Range and Precision Storage
Exact Numerics bigint -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807) 8 Bytes
bit    
decimal 1 - 9 5
10-19 9
20-28 13
29-38 17
int -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647) 4 Bytes
money -922,337,203,685,477.5808 to 922,337,203,685,477.5807 (-922,337,203,685,477.58
to 922,337,203,685,477.58 for Informatica. Informatica only supports two decimals, not four.)
8 bytes
numeric 1 - 9 5
10-19 9
20-28 13
29-38 17
smallint -2^15 (-32,768) to 2^15-1 (32,767) 2 Bytes
smallmoney - 214,748.3648 to 214,748.3647 4 bytes
tinyint 0 to 255 1 Byte
Approximate Numerics float - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 Depends on the value of n
real - 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38 4 Bytes
Date and Time date 0001-01-01 through 9999-12-31 (1582-10-15 through 9999-12-31 for Informatica) January 1, 1 CE through December 31, 9999 CE (October 15, 1582 CE through December 31, 9999 CE for Informatica) 3 bytes, fixed
datetime2 0001-01-01 through 9999-12-31 January 1,1 CE through December 31, 9999 CE 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.
datetime (Date) January 1, 1753, through December 31, 9999, (Time) 00:00:00 through 23:59:59.997 8 bytes
datetimeoffset (Date) 0001-01-01 through 9999-12-31 January 1, 1 CE through December 31, 9999 CE, (Time) 00:00:00 through 23:59:59.9999999 (fractional seconds are not supported in Informatica), (Time zone offset range) -14:00 through +14:00 (the time zone offset is ignored in Informatica) 10 bytes, fixed is the default with the default of 100ns fractional second precision.
smalldatetime (Date)1900-01-01 through 2079-06-06 January 1, 1900, through June 6, 2079, (Time) 00:00:00 through 23:59:59 2007-05-09 23:59:59 will round to 2007-05-10 00:00:00 4 bytes, fixed.
time 00:00:00.0000000 through 23:59:59.9999999 (00:00:00.000 through 23:59:59.999 for Informatica) 5 bytes, fixed, is the default with the default of 100ns fractional second precision. In Informatica, the default is 4 bytes, fixed, with the default of 1ms fractional second precision.
Character Strings char Fixed-length, non-Unicode string data. n defines the string length and must be a value from 1 through 8,000. The storage size is n bytes. The ISO synonym for char is character.  
text Variable-length non-Unicode data in the code page of the server and with a maximum string length of 2^31-1 (2,147,483,647). When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes. Depending on the character string, the storage size may be less than 2,147,483,647 bytes.  
varchar Variable-length, non-Unicode string data. n defines the string length and can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size is the actual length of the data entered + 2 bytes. The ISO synonyms for varchar are charvarying or charactervarying.  
Unicode Character Strings nchar Fixed-length Unicode string data. n defines the string length and must be a value from 1 through 4,000. The storage size is two times n bytes. When the collation code page uses double-byte characters, the storage size is still n bytes. Depending on the string, the storage size of n bytes can be less than the value specified for n. The ISO synonyms for nchar are national char and national character..  
ntext Variable-length Unicode data with a maximum string length of 2^30 - 1 (1,073,741,823) bytes. Storage size, in bytes, is two times the string length that is entered. The ISO synonym for ntext is national text.  
nvarchar Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size, in bytes, is two times the actual length of data entered + 2 bytes. The ISO synonyms for nvarchar are national char varying and national character varying.  
Binary Strings binary Fixed-length binary data with a length of n bytes, where n is a value from 1 through 8,000. The storage size is n bytes.  
image Variable-length binary data from 0 through 2^31-1 (2,147,483,647) bytes.  
varbinary Variable-length binary data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of the data entered + 2 bytes. The data that is entered can be 0 bytes in length. The ANSI SQL synonym for varbinary is binary varying.  
Other Data Types cursor    
hierarchyid    
sql_variant    
table    
timestamp    
uniqueidentifier    
xml    
Spatial Types    

No comments:

Post a Comment