Is this a SQL Server bug?

Source: Internet
Author: User

You can see this post on the Forum. The original Article is as follows:

On My SQL Server R2, I tried it. As a result, an error is returned when it is converted to numeric ..

It seems strange that the returned value of isnumberic is 1, but the conversion fails. Why?

I checked the BOL and found the following explanation:

The isnumberic function determines whether an expression is of any of the following types:

 

IntReal

Numeric bigint

Money smallint

Smallmoney tinyint

Float decimal


Isnumberic not only determines whether it is of the numberic type, but also determines whether it is of other types such as money.

After converting to the money type, no error is returned. The statement is as follows:

Select cast ('2014 4 'as money );

In addition, if the $ symbol is available, the conversion is successful. The statement is as follows:

Select isnumeric ('$123 ');
Select cast ('$123' as money );

To sum up, this is not a SQL Server bug, but it is easy for usersNumbericI think that the expression 1 returned by this function can be converted to the numberic type. In fact, it can be converted to the money type but not the numberic type. isnumberic determines that 1 is returned.

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.