Home > Articles > Different Data Types available in SQL Server  


Different Data Types available in SQL Server

Data Types - Character based
Non Unicode Character based Data Types required 1 byte to store a character. Unicode Character based Data Types required 2 byte to store a character.

  • char (Non Unicode) - Fixed length and size up to 8000 bytes.
  • varchar  (Non Unicode) - Variable Length.
  • text  (Non Unicode) - For long values.
  • varchar(max)  (Non Unicode) - For long values.
  • nchar (Unicode) - Fixed length and size up to 4000 bytes.
  • nvarchar  (Unicode) - Variable Length.
  • ntext  (Unicode) - For long values.
  • nvarchar(max)  (Unicode) - For long values.

Data Types - Numeric

  • bit - 1 or zero which is equivalent to one bit.
  • tinyint - 0 to 255 with size of one byte.
  • smallint - (-32768) to (+32768) with size of two bytes.
  • int - (-2,147,483,64) to (+2,147,483,64) with size of four bytes.
  • bigint - (-9,223,372,036,854,775,80) to (+9,223,372,036,854,775,80) with size of 8 bytes.
  • real - Floating point value with size of 4 bytes.
  • float - Floating point value with a maximum storage size of 8 bytes.
  • decimal / numeric - scaled integer, precision - maximum number of digits 38. scale - digit which is found right of the decimal.
  • money - (-922,337,203,685,477.5808) to (922,337,203,685,477.5807) is a scaled integer with a storage size of 8 bytes with four digits to the right of the decimal
  • smallmoney - (-214,748.3648) to (214,748.3647) is a scaled integer with a storage size of 4 bytes with four digits to the right of the decimal.

Data Types - Date and Time

  • datetime - Storage size is 8 bytes. Range starts from 01/01/1753 to 12/31/9999 and time range 00:00:00 to 23:59:59.997. Default value for this data type is 01/01/1900 00:00:00
  • smalldatetime - Storage size is 4 bytes. range starts from 01/01/1900 to 06/06/2079 and time range 00:00:00 to 23:59:59. . Default value for this data type is 01/01/1900 00:00:00
  • date - Storage size is 3 bytes. Range starts from 01/01/0001 to 12/31/9999
  • time - Storage size is in between 3 to 5 bytes. Time range starts from 00:00:00.0000000 to 23:59:59.9999999
  • datetime2 - Storage size is 6 to 8 bytes. Range starts from 01/01/0001 to 12/31/9999 and time ranges from 00:00:00 o 23:59:59:9999999
  • datetimeoffset - Storage size is 8 to 10 bytes. This we can say as time zone information with datetime2.

Data Types -Binary

  • binary - Storage size of up to 8000 bytes with fixed length
  • varbinary - variable length binary
  • image - Storage size of up to 2,147,483,647 bytes

Data Types - Others

  • uniqueidentifier - A 16 byte GUID


Welcome Guest
Sign In | Register