Retain ten valid numbers

Source: Internet
Author: User
There are no DECLARE @ execsqlNVARCHAR (1024) SET @ execsqlNSELECTCAST (+ CAST (125.365412354 ASNVARCHAR (20) + NASNUMERIC (20, + STR (10-CEILING (LOG10 (125.365412354) + N) EXECSP_EXECUTESQL @ execsql * ROUND? (? Nu

SQL rounding up the ten valid digits with the reserved floating point number without DECLARE @ execsql NVARCHAR (1024) SET @ execsql = n' SELECT CAST ('+ CAST (125.365412354 AS NVARCHAR (20 )) + N' as numeric (20, '+ STR (10-CEILING (LOG10 (125.365412354) + N')' EXEC SP_EXECUTESQL @ execsql/* ROUND? (? Nu

Returns 10 valid digits of a floating point number. <无>
DECLARE @execsql NVARCHAR(1024)SET @execsql =N'SELECT CAST('+CAST(125.365412354 AS NVARCHAR(20)) +N' AS NUMERIC (20,'+STR(10-CEILING(LOG10(125.365412354)))+N'))'EXEC SP_EXECUTESQL @execsql
/* ROUND? (? Numeric_expression ?,? Length? [?, Function?]?) Function? Required? Tinyint, smallint ?? Or? Int. If omitted? Function? Or its value is? 0 (default), it will be round? Numeric_expression. If a value other than 0 is specified, it is truncated? Numeric_expression. */SELECT? ROUND (150.45648 ,? 2); -- keep the last two digits of the decimal point, which should be rounded to SELECT? ROUND (150.45648 ,? 2 ,? 0); -- retain the two digits after the decimal point. 0 is the default value, which indicates rounding the SELECT? ROUND (150.45648 ,? 2 ,? 1); -- keep the two digits after the decimal point, and do not need to be rounded to the nearest decimal point. The SELECT? ROUND (150.45648 ,? 2 ,? 2); -- keep the last two digits of the decimal point, and do not need to be rounded up. All values except 0 have the same effect -- 150.46000 -- 150.45000 -- 150.45000 -- 150.45000 --

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.