Ignore Arithmetic Overflow in microsoft sql server(忽略 microsoft sql server 中的算术溢出)
问题描述
我正在 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 中的算术溢出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:忽略 microsoft sql server 中的算术溢出
基础教程推荐
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01