Decimal out of range

2019-04-19 11:15发布

问题:

I'm trying to store the decimal 140.2705893427 into a SQL Server 2012 table. The column has a data type of decimal(12, 10) but I get the error:

{"Parameter value '140.2705893427' is out of range."}

Why is this?

回答1:

decimal(12, 10) means 12 total digits, 10 of which may be after the decimal point.

Your value of 140.2705893427 has 13 total digits, thus it is out of range.

Read decimal and numeric (Transact-SQL) for documentation.