SQL Server retains decimal resolution

Source: Internet
Author: User

In the database, we sometimes use decimals, how to convert the decimal in the database, the following are some common methods.

1. Use the round (field name/number, decimal reserve number) method as follows:

Select Round (3.333,2)

The results are as follows:

2. Use the CONVERT (decimal (18, decimal reserved digit), field name/number method, as follows:

Select Convert (Decimal (18,1), 3.333)

The results are as follows:

The difference between the two methods is that the number of digits after the decimal point of the round function is constant, the number following the reserved digit is replaced by 0, and the Convert method retains only the number of decimal places you need.

SQL Server retains decimal resolution

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.