Collections:

Other Resources:

Differences of DECIMAL and FLOAT in SQL Server

Q

What Are the Differences between DECIMAL and FLOAT in SQL Server Transact-SQL?

✍: FYIcenter.com

A

DECIMAL and FLOAT are both used to store numerical values. But they have the following main differences:

- DECIMAL(p,s) stores values with the decimal point fixed at the position of s (scale) digits from the right. The total number of decimal digits is also fixed as p (precision).
- FLOAT(n) stores values with the decimal point floating based on the value. The number of bits used to store the mantissa part is fixed as n.
- If the input value of DECIMAL(p,s) has more digits after the decimal point than the scale s, the value will be rounded to the scale s.
- If the input value of FLOAT(n) has more total digits (mantissa) than what n bits can store, the value will be rounded to fit the storage size.
- If the input value of DECIMAL(p,s) has more digits before the decimal point than p-s, SQL Server will give you an over-flow error.
- If the input value of FLOAT(n) is too big that the exponential part goes over the positive limit, SQL Server will give you an over-flow error.
- If the input value of FLOAT(n) is too small that the exponential part goes over the negative limit, SQL Server will give you an under-flow error.

2017-04-15, 476👍, 0💬

Popular Posts:

How to download and install the scaled-down database AdventureWorksLT in SQL Server? If you want to ...

How to put statements into a statement block in SQL Server Transact-SQL? You can put statements into...

Where to find answers to frequently asked questions on Managing Security, Login and User in SQL Serv...

What are DDL (Data Definition Language) statements for tables in SQL Server? DDL (Data Definition La...

Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...