Precision problems with decimal or numeric in SQL Server _mssql

Source: Internet
Author: User
Tags numeric
What is precision: The total number of decimal digits that can be stored, including the left and right digits of the decimal point. The precision must be a value from 1 to the maximum precision 38. The default precision is 18.
Scale: The maximum number of decimal digits that can be stored to the right of the decimal point. The number of decimal places must be a value from 0 to P. You can specify the number of decimal places only after you specify the precision. The default number of decimal places is 0; therefore, 0 <= s <= p. The maximum storage size varies based on precision.
It is also necessary to set the precision of the parameter and the number of decimal digits when invoking the SqlParameter parameter in C Sharp, as the following example declares a decimal type parameter with a precision of 18 small tree digits of 2:
Copy Code code as follows:

SqlParameter parm = new SqlParameter ("@parmName", sqldbtype.decimal);
Parm. Precision = 18;
Parm. Scale = 2;
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.