The document provides a cheat sheet of SQL Server data types categorized by data type, size, and value range. It lists exact numeric, approximate numeric, character string, Unicode character string, binary string, date and time, and spatial data types. Some data types like int store integers from -2 billion to 2 billion while text can store over 2 billion Unicode characters. Date/time types range from year 1753 to 9999 and include fractional seconds in higher precision types.
The document provides a cheat sheet of SQL Server data types categorized by data type, size, and value range. It lists exact numeric, approximate numeric, character string, Unicode character string, binary string, date and time, and spatial data types. Some data types like int store integers from -2 billion to 2 billion while text can store over 2 billion Unicode characters. Date/time types range from year 1753 to 9999 and include fractional seconds in higher precision types.
Bit 1 1, 0, or NULL. Tinyint 1 0 to 255 Smallint 2 -2^15 (-32,768) to 2^15-1 (32,767) Int 4 -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647) -2^63 (-9,223,372,036,854,775,808) to 2^63-1 Exact numeric Bigint 8 (9,223,372,036,854,775,807) Smallmoney 4 - 214,748.3648 to 214,748.3647 Money 8 -922,337,203,685,477.5808 to 922,337,203,685,477.5807 numeric[ (p[ ,s] )] 5-17 decimal [ (p[ ,s] )] 5-17 Float 4-8 - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 Approximate numeric Real/float(24) 4 - 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38 char [ ( N ) ] N N = 1 to 8000 non-Unicode characters bytes N or N = 1 to 8000 non-Unicode characters bytes Character strings varchar [ ( N or max ) ] 2^31-1 Max = 2^31-1 bytes (2 GB) non-Unicode characters bytes Text 2^31-1 1 to 2^31-1 (2,147,483,647) non-Unicode characters bytes nchar [ ( N ) ] N N = 1 to 4000 UNICODE UCS-2 bytes N or N = 1 to 4000 UNICODE UCS-2 bytes Unicode character strings nvarchar [ ( N | max ) ] 2^31-1 1 to 2^31-1 (2,147,483,647) UNICODE UCS-2 bytes Ntext 2^30-1 Maximum size 2^30 - 1 (1,073,741,823) bytes binary [ ( N ) ] N N = 1 to 8000 bytes N or N = 1 to 8000 bytes Binary strings varbinary [ ( N | max) ] 2^31-1 Max = 0 to 2^31-1 bytes Image 2^31-1 0 to 2^31-1 (2,147,483,647) bytes Uniqueidentifier 16 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (hex decimal) Timestamp 8 binary(8) or varbinary(8) rowversion 8 binary(8) or varbinary(8) xml 2^31-1 xml( [ CONTENT | DOCUMENT ] xml_schema_collection ) Other data types sql_variant 8016 data type that stores values of various SQL Server-supported data types Hierarchyid 892 6*logAn bits where n is child node Cursor Table Sysname 256 Date 3 0001-01-01 through 9999-12-31 time [ (fractional second 3 to 5 00:00:00.0000000 through 23:59:59.9999999 precision) ] Date: 1900-01-01 through 2079-06-06 Smalldatetime 4 Time: 00:00:00 through 23:59:59 Date: January 1, 1753, through December 31, 9999 Date and time Datetime 8 Time: 00:00:00 through 23:59:59.997 datetime2 [ (fractional Date: 0001-01-01 through 9999-12-31 6 to 8 seconds precision) ] Time: 00:00:00 through 23:59:59.9999999 Date: 0001-01-01 through 9999-12-31 datetimeoffset [ (fractional 8 to 10 Time: 00:00:00 through 23:59:59.9999999 seconds precision) ] Time zone offset: -14:00 through +14:00 Geography 2^31-1 Spatial Geometry 2^31-1
Note: text, ntext, image and timestamp data type will be removed from future version.