Numeric Data Types in SQL Server

  Total Views : 486
  Comments : 0
 
  Keywords : Types of numeric data types in sql server, Exact numeric data types in sql server, Approximate numeric data types in sql server

Here we will learn what are the numeric data types in sql server and use of numeric data types and different types of sql numeric data types.

SQL Numeric Data Types

Generally in SQL we will use these numeric data types whenever we want to insert only numeric values in columns in that case we will define those columns types as numeric data types. 

 

For example in SQL we have one table with multiple columns in that one column name is “Amount” in this column always we need to store only numeric values in that case we will define this column type as numeric data types. In SQL we have two different numeric data types those are

 

    - Exact Numeric Data Types

 

    - Approximate Numeric Data Types 

Exact Numeric Data Types in SQL

The exact numeric data types in sql will used to store integer type of data. Please check below of table for exact numeric data types

 

Data TypeDescriptionStorage Size
bit It’s single bit integer that can take values of 0, 1 or null  
tinyint It’s single Byte integer we can store values from 0 to 255 (Minval: 0, Maxval: 255) 1 Byte
smallint It’s 16 bit integer we can store values from -2^15 (-32,768) to 2^15 - 1 (32,767) 2 Bytes
int It’s 32 bit integer we can store values from -2^15 (-32,768) to 2^15 - 1 (32,767) 4 Bytes
bigint It’s 64 bit integer we can store values from -2^63 (-9223372036854775808) to 2^63-1 (9223372036854775807) 8 Bytes
decimal We can store values from -10^38 1 to 10^38 –1 5 - 17 Bytes
numeric We can store values from -10^38 1 to 10^38 –1 5 - 17 Bytes
smallmoney We can store monetary values from - 214,748.3648 to 214,748.3647 4 Bytes
money We can store moneytary values from -922,337,203,685,477.5808 to 922,337,203,685,477.5807 8 Bytes

Approximate Numeric Data Types in SQL

Approximate numeric data types in sql is used to store numeric data with floating point i.e. floating point data is approximate therefore not all values in the data type range can be represented exactly.

 

Data TypeDescriptionStorage Size
Float(n) We can store values from - 1.79E 308 to 1.79E 308 Depends on value of n
real We can store values from - 3.40E 38 to 3.40E 38 4 Bytes

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User