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?
To fix the error, change your datatype to VARCHAR . Phone and Fax numbers should be stored as strings.
The precision represents the number of significant digits that are stored for values, and the scale represents the number of digits that can be stored following the decimal point. This would allow for a range of -9,999,999,999,999.99 to -9,999,999,999,999.99.
To fix the issue, we will have to store a less than 2147483647 or change the data type of student_ssn_no to BIGINT. Let us modify the column to BIGINT and try inserting the data again.
When MySQL stores a value in a numeric column that is outside the permissible range of the column data type, the result depends on the SQL mode in effect at the time: If strict SQL mode is enabled, MySQL rejects the out-of-range value with an error, and the insert fails, in accordance with the SQL standard.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With