ASP.NET,C#.NET,VB.NET,JQuery,JavaScript,Gridview,SQL Server,Ajax,jQuery Plugins,jQuery UI,SSRS,XML,HTML,jQuery demos,code snippet examples.

Breaking News

  1. Home
  2. sql
  3. Data Types in SQL Server

Data Types in SQL Server

The data type is an attribute that defines the type of data that the object can hold. During table creation we have to decide what types of data will be stored inside each and every column. SQL Server provides a set of system data types that define all the types of data that can be used. We can also define our own data types in Transact-SQL. This article describes about the data types in SQL Server 2012. Summary of the article:
  • Data Types in SQL Server 2012
  • Category of Data Types
  • Exact numeric Data Types
  • Approximate numeric Data Types
  • Date and time Data Types
  • Character strings Data Types
  • Unicode character strings Data Types
  • Binary strings Data Types
  • Other data types
Data Types in SQL Server 2012
In SQL Server, each column, local variable, parameter, and expression has a related data type. We would use these data types while creating our tables. We would choose a particular data type for a table column based on our system structure and requirement.
Category of Data Types
Data types in SQL Server are organized into the following categories:
  • Exact numeric Data Types
  • Approximate numeric Data Types
  • Date and time Data Types
  • Character strings Data Types
  • Unicode character strings Data Types
  • Binary strings Data Types
  • Other data types
Exact Numeric Data Types  
The data types of exact numeric data are given bellow:  
  • bigint
  • numeric
  • bit
  • smallint
  • decimal
  • smallmoney
  • int
  • tinyint
  • money
Approximate Numeric Data Type
The data types of approximate numeric data are given bellow:
  • float
  • real
Date and Time Data Types  
The data types of date and time are given bellow:
  • date
  • datetimeoffset
  • datetime2
  • smalldatetime
  • datetime
  • time
Character Strings Data Types  
The data types of character strings are given bellow:
  • char
  • varchar
  • text
Unicode Character Strings Data Types
The data types of Unicode character strings are given bellow:
  • nchar
  • nvarchar
  • ntext
Binary Strings Data Types  
The data types of binary strings are given bellow:
  • binary
  • varbinary
  • image
Other Data Types 
The others type of data are given bellow:
  • cursor
  • timestamp
  • hierarchyid
  • uniqueidentifier
  • sql_variant
  • xml
  • table
At present many relational databases are present and data types might have different names in different database. And even if the name is same, the size and other characteristics may be different. We should choose the appropriate data type for a column of a table based on our requirements.

No comments