Datatypes in SQL Server

There are two types of data types in SQL Server
  1. Simple data types
  2. User defined data types
1. Simple data types:
  • The data types provided by software are called simple data types.
a. Character Data types:
  1. Char(n):
  • It is a fixed length data type used to store the character data.
  • Default size is 1 byte
  • Memory wastage if not used
  • Maxi size is allowed for n is  800 bytes.

    2. Varchar(n):
  • It is a character data type used to store the character data.
  • It is variable length data type.
  • Default size is n byte
  • Maxi size is 800 bytes.
  • Unnecessary memory is not allocated
  • no memory wastage.
    3. nchar(n):
  • It is the fixed length charcter data type used to store the character data.
  • Maximum size of 'n' is 400 bytes.
    4. nvarchar(n):
  • It is the variable length character data type used to store the character data.
  • Maximum size - 400 bytes
b. Numeric Data Types:
Numeric data types
c. Date Data Types:

Used to store date and time values.
  1. datetime: 
  • It is used to store date values from 1st January 1753 to 31-December-9999.
  • Default size is 8 bytes.
    2. smalldatetime:
  • It is used to store date value from 1st January 1900 to 6th June 2079
  • Default size is 4 bytes.
                                                                             Back to SQL Tutorial Index

No comments:

Post a Comment