SQL SERVER - DATA TYPES

Numeric Data Types
Data TypeDescriptionLength
intStores integer values ranging from -2,147,483,648 to 2,147,483,6474 bytes
tinyintStores integer values ranging from 0 to 2551 byte
smallintStores integer values ranging from -32,768 to 32,7672 bytes
bigintStores integer values ranging from -253 to 253-18 bytes
moneyStores monetary values ranging from -922,337,203,685,477.5808 to 922,337,203,685,477.58078 bytes
smallmoneyStores monetary values ranging from -214,748.3648 to 214,748.36474 bytes
decimal(p,s)Stores decimal values of precision p and scale s. The maximum precision is 38 digits5–17 bytes
numeric(p,s)Functionally equivalent to decimal5–17 bytes
float(n)Stores floating point values with precision of 7 digits (when n=24) or 15 digits (when n=53)4 bytes (when n=24) or
8 bytes (when n=53)
realFunctionally equivalent to float(24)4 bytes
Date and Time Data Types
Data TypeDescriptionLengthExample
dateStores dates between January 1, 0001, and December 31, 99993 bytes2008-01-15
datetimeStores dates and times between January 1, 1753, and December 31, 9999, with an accuracy of 3.33 milliseconds8 bytes2008-01-15 09:42:16.142
datetime2Stores date and times between January 1, 0001, and December 31, 9999, with an accuracy of 100 nanoseconds6–8 bytes2008-01-15 09:42:16.1420221
datetimeoffsetStores date and times with the same precision as datetime2 and also includes an offset from Universal Time Coordinated (UTC) (also known as Greenwich Mean Time)8-10 bytes2008-01-15 09:42:16.1420221
+05:00
smalldatetimeStores dates and times between January 1, 1900, and June 6, 2079, with an accuracy of 1 minute (the seconds are always listed as “:00”)4 bytes2008-01-15 09:42:00
timeStores times with an accuracy of 100 nanoseconds3–5 bytes09:42:16.1420221

Character String Data Types
Data TypeDescriptionLength
char(n)Stores n charactersn bytes (where n is in the range of 1–8,000)
nchar(n)Stores n Unicode characters2n bytes (where n is in the range of 1–4,000)
varchar(n)Stores approximately ncharactersActual string length +2 bytes (where n is in the range of 1–8,000)
varchar(max)Stores up to 231–1 charactersActual string length +2 bytes
nvarchar(n)Stores approximately ncharacters2n(actual string length) +2 bytes (where n is in the range of 1–4,000)
nvarchar(max)Stores up to ((231–1)/2)–2 characters2n(actual string length) +2 bytes

Binary Data Types
Data TypeDescriptionLength
bitStores a single bit of data1 byte per 8 bit columns in a table
binary(n)Stores n bytes of binary datan bytes (where n is in the range of 1–8,000)
varbinary(n)Stores approximately n bytes of binary dataActual length +2 bytes (where n is in the range of 1–8,000)
varbinary(max)Stores up to 231–1 bytes of binary dataActual length +2 bytes

Other Data Types
Data TypeDescriptionLength
cursorStores a reference to a cursorN/A (cannot be used in a table)
sql_variantMay store any data type other than sql_variant, text, ntext, image, and timestampUp to 8,000 bytes
tableStores a temporary table (such as a query result)N/A (cannot be used in a table)
rowversionStores a value of the database time (a relative number that increments each time you insert or update data in a database. It is not related to calendar/clock time)8 bytes
uniqueidentifierStores a globally unique identifier2 bytes
xmlStores formatted XML documentsUp to 2GB















Comments

Popular posts from this blog

PUTTY - The server's host key is not cached in the registry cache

OIM-12c Installation - FMW - SOA - IDM

SAML & OAuth 2.0