Precision of decimal or numeric in sqlserver-mysql tutorial

Source: Internet
Author: User
Tags mysql tutorial
When defining the data type decimal of a column in sqlserver, the precision and number of decimal places must be specified.

When defining a column's data type decimal in SQL server, you must specify its precision and number of decimal places.

Precision: The total number of digits in the decimal place, including the digits on the left and right of the decimal point. The precision must be between 1 and 38. The default precision is 18.
Decimal places: the maximum number of digits in decimal places that can be stored on the right of the decimal point. The number of decimal places must be between 0 and p. The number of decimal places can be specified only after the precision is specified. The default number of decimal places is 0. Therefore, 0 <= s <= p. The maximum storage size varies based on precision.
When calling the SqlParameter parameter in c sharp, you also need to specify the parameter precision and the decimal number. the following example declares a decimal type parameter with the precision of 2 in 18 small trees:
The code is as follows:
SqlParameter parm = new SqlParameter ("@ parmName", SqlDbType. Decimal );
Parm. Precision = 18;
Parm. Scale = 2;

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.