Cheat Sheet Data Type Sqlserver
Cheat Sheet Data Type Sqlserver
www.databasestar.com
Numeric Character
Integer value, uses 8 bytes. CHAR (n) Fixed-size string. Parameter “n” is the number of bytes between
BIGINT
Range from -2^63 (-9,223,372,036,854,775,808) to 2^63-1 1 and 8,000. Unused characters are padded with spaces.
(9,223,372,036,854,775,807)
NCHAR (n) Fixed-size string for Unicode data. Parameter “n” is the number
BIT Integer data type. Can take 1, 0, or NULL. Often used as a of bytes between 1 and 4,000. Unused characters are padded
boolean. with spaces.
DECIMAL (p [,s]) Decimal number. Uses precision “p” which is the total number of
VARCHAR (n) Variable-size string. Parameter “n” is the maximum number of
decimal digits (both left and right of decimal). Default 18. The
bytes between 1 and 8,000. If “n” is max, then the value of 2^31-
scale “s” is the number of digits to the right of the decimal.
1 is used (2 GB)
Default 0. Range -10^38 +1 through 10^38 - 1
Range 2^31-1 (2,147,483,647 or 2GB)
FLOAT(n) Approximate number, with “n” is the number of bits used to store CHARACTER Synonym for VARCHAR
the value. Default is 53. VARYING
Range – 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to
BINARY VARYING Synonym for VARBINARY
1.79E+308
Date CURSOR Used for variables or stored procedure out parameters to refer to
a cursor
DATE Defines and stores a date value.
Range 0001-01-01 through 9999-12-31
ROWVERSION Used to store automatically-generated unique binary numbers. 8
bytes
DATETIME Date and time, with fractional seconds.
Date: January 1, 1753, through December 31, 9999
Time: 00:00:00 through 23:59:59.997 HEIRARCHYID Variable length system data type
DATETIME2 (s) Date and time, with fractional seconds, with a larger range
UNIQUEIDENTIFIER A 16-byte GUID (Global Unique Identifier). Uses 16 bytes.
than DATETIME. Scale “s” is the number of digits for the
fraction of seconds
Date: 0001-01-01 through 9999-12-31 SQL_VARIANT Stores values of different SQL Server data types
Time: 00:00:00 through 23:59:59.9999999
TIME (s) Time of day, without a timezone. Scale “s” is the number of digits
for the fraction of seconds
Range: 00:00:00.0000000 through 23:59:59.9999999