SQL data types

A datatype is a attribute wich specifies the type of data the object can hold

There are not that much datatypes in SQL server, we can divide them in the following groups:

  • Exact numerics
  • Approximate Numerics
  • Date and Time
  • Character Strings
  • Unicode Character Strings
  • Binary Strings
  • Other Data Types

Before choosing a data-type for your collumn think about this:

  • Always column size. The smaller the size of the column the faster the query and the lower storage needed on the disk!
  • Always the smalles data type, use int instead of varchar etc.
  • Use int for the PK ( always ) unless there is no other option!
  • If the column needs to be sorted consider Int as data-type in advance of character based.

Unicode VS ASCI data-types

The unicode datatypes( nchar, nvarchar ) are two bytes and 1 byte bigger than the ASCI datatypes (char, varchar).

Choose for Unicode

  • If your application is multi-lingual go for UNICODE
  • If you are planning to include CLRDatatype in the database you have to use UNICODE Datatypes
  • For web-based applications better to go for UNICODE
  • If you column is not nullable and smaller as 20 characters use ASCI




Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!