SQL Server 2008 Data types

Today I'll will mention the Microsoft SQL Server 2008 Fileds data types, you need to choose the right data type for the database fileds for more speed efficency, and i think the most important thing the fundamental of the database itself.
Let's begin:
  1. char: the char datatype is ifxed in length, if you enter fewer that than the number of character defined the remaining length will be space filled to the right; use this data type when the column dat is to be of fixed length, which tends to be the case foe customer IDs and bank account IDs.
  2. nchar: the nchar type is exactly like char, but will hold characters in unicode formate rather than ANSI; infact SQL Server allocates double the space internally, so unless there is a need in your database to hold this type of character, it's easier to stick with ANSI.
    • Note:
      • ANSI character sets only hold up to 256 char.
      • Unicode character sets only hold up to 65,536 chr.
  3. varchar: the varchar data type holds alphanumeric data; just like char but with flexible size, you just set the maximum number of characters, maximum size is 8,000 character.
  4. nvachar: it's defined in samilier way to varcar but it uses unicode.
  5. text: the text data type holds data is longer than 8,000.
  6. ntext: sae as text type, but holde unicode.
  7. image: is very much like text data tybe, expect it's for any type of binary data, like images, movies, or music.
  8. int: the integer data type is used for holding a anumeric values that don't have any deciaml point, it's rang is between -2,147,483,648 adn 2,147,483,674.
  9. bigint: the bidint or big integer data type same as int but with larger rang, it's rang is between -9,223,372,036,854,77,808 and 9,223,372,036,854,77,807.
  10. smallint: the smallint data type is samilar to int but with smaller rang, it's rang is between -32,768 to 32,767.
  11. tinyint: it's  samller  than smallint data type.
  12. decimal/numeric: both the decimal and numeric data types hold the same rang of data from -10 to the power 38+1 to 10 to he power 38-1.
  13. float: it's used for numbers where the decimal point isn't fixed, it's rang is between -1.79e+308 to 1.79e+308
    • Warning:
      • The values can't always be seen as 100% accurate, as they can be approximate "Rounded".
  14. real: it's like float data type but with wider rand, it's rang between -3.40e+38 to 3.40e+38, and still hold approximate value also.

Comments

Popular posts from this blog

Add Serial no in crystal report without coding

Working with Oracle's BLOB and Microsoft's C#

File operations in C# (.net)