我正在 SQLServer 中进行一些操作.并且遇到了著名的算术溢出"错误.情况是,我希望它溢出.我如何告诉它允许溢出并忽略错误?
I'm doing some bit manipulations in SQLServer. And have encountered the famous "Arithmetic Overflow" error. The case is, I want it to overflow. How can I tell it to allow overflow and ignore the error?
我正在做这个选择:
SELECT CONVERT(bigint, 0x8000000000000000)-1
我希望它返回 9223372036854775807(最大的 bigint),但它返回:
I want this to return 9223372036854775807 (the biggest bigint), but it returns:
Arithmetic overflow error converting expression to data type bigint.
这个怎么样:
SET ARITHABORT OFF;
SET ARITHIGNORE ON;
SET ANSI_WARNINGS OFF;
SELECT ISNULL(CONVERT(bigint, 0x8000000000000000)-1, 9223372036854775807)
请参阅关于 ARITHIGNORE 和 ARITHABORT
这篇关于忽略 microsoft sql server 中的算术溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!