Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Data type in MsSQL Server

Data type Length Description
bigint 8 Integer from -2^63 (-9 223 372 036 854 775 808) to 2^63-1 (9 223 372 036 854 775 807).
int 4 Integer from -2^31 (-2 147 483 648) to 2^31-1 (2 147 483 647).
smallint 2 Integer from -2^15 (-32 768) to 2^15-1 (32 767).
tinyint 1 Integer from 0 to 255.
bit 1 bit Integer 0 or 1.
decimal(precision, scale) 5-17 Numeric data type with fixed precision and scale (precision 1-38, 18 by default and scale 0-p, 0 by default).
numeric 5-17 Same as data type 'decimal'.
money 8 Financial data type from -2^63 (-922 337 203 685 477.5808) to 2^63-1 (922 337 203 685 477.5807) with the precision of one ten-thousandth unit.
smallmoney 4 Financial data type from -2^31 (-214 748.3648) to 2^31-1 (214 748.3647) with the precision of one ten-thousandth unit.
float(n) 4-8 Numeric data type with float precision, where n is the number of mantis bits (1-24, precision of 7 digits, size of 4 bytes and 25-53, precision of 15 digits and size of 8 bytes).
real 4 Numeric data type with float precision that is defined as a float(24).
datetime 8 Data type representing date and time from 1.1.1753 to 31.12.9999 with precision about 3ms. Values are rounded to .000, .003 and .007.
smalldatetime 4 Data type representing date and time from 1.1.1900 to 6.6.2079 with precision of 1min. Values up to 29.998 are rounded down and values from 29.999 are rounded down to the nearest minute.
char n Char string of fixed length and max. length of 8000 chars.
varchar n Char string of variable length and max. length of 8000 chars.
text n Char string of variable length and max. length of 2^31-1 (2 147 483 647) chars.
nchar 2*n Unicode char string of fixed length and max. length of 4000 chars.
nvarchar 2*n Unicode char string of variable length and max. length of 4000 chars.
ntext 2*n Unicode char string of variable length and max. length of 2^30-1 (1 073 741 823) chars.
binary n+4 Binary data of fixed length and max. length of 8000 bytes.
varbinary n+4 Binary data of variable length and max. length of 8000 bytes.
image n Binary data of variable length and max. length of 2^31-1 (2 147 483 647) bytes.
cursor   For storing the reference to cursors in a variable or in a procedure (no for CREATE TABLE).
sql_variant   For storing value of another type (no text, ntext, image, timestamp, sql_variant) of max. length to 8016 bytes. ODBC doesn't fully support this data type.
table   For storing the query result for the later usage.
timestamp 8+4 Data type generates automatically binary numbers, unique in the database, used mostly to the rows identification. There can be only column of this data type in the table.
uniqueidentifier   Data type for storing GUID (new by means of the NEWID function or existing from the string in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, for example 6F9619FF-8B86-D011-B42D-00C04FC964FF).
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice