numeric and int in SQL Server

Source: Internet
Author: User
Tags dotnet

Type mapping

Https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings

C # Keywords decimal

Https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/decimal

The decimal keyword indicates a 128-bit data type.

Compared to other floating-point types, the decimal type have more precision and a smaller range, which makes it appropriate For financial and monetary calculations.

The approximate range and precision for the decimal type is shown in the following table.

Range of values ( -7.9 x 1028 to 7.9 x 1028)/(from 1028)

Accuracy 28-29 significant digits

Int

Https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/int

intDenotes an integral type This stores values according to the size and range shown in the following table.

Value range -2,147,483,648 to 2,147,483,647

Size signed 32-bit integer

In SQL Server

Https://docs.microsoft.com/en-us/sql/t-sql/data-types/decimal-and-numeric-transact-sql

Numeric data types that has a fixed precision and scale. Decimal and numeric is synonyms and can be used interchangeably.

decimal [ (p[ ,s] )] and numeric[ P[, S] )]
Fixed precision and scale numbers.

When maximum precision was used, valid values is from-10^38 +1 through 10^38-1.

The ISO synonyms for decimal is Dec and Dec (P, s).

numeric is functionally equivalent to decimal.

P (Precision)

The maximum total number of a decimal digits that would be stored, both to the left and to the right of the decimal point.

The precision must is a value from 1 through the maximum precision of 38. The default precision is 18.

s(scale)

The number of decimal digits that would be stored to the right of the decimal point.

This was subtracted from p to determine the maximum number of digits to the left of the decimal point.

The maximum number of decimal digits that can is stored to the right of the decimal point.

Scale must is a value from 0 through p.

Scale can specified only if precision is specified.

The default scale is 0; Therefore, 0 <= s <= p.

Maximum storage sizes vary, based on the precision.

Example

Numeric (18,2) range of values

Max 9999999999999999.99 decimal Right two digits, left 16 digits

numeric and int in SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.