【问题标题】:"Arithmetic overflow error converting expression to data type int"“将表达式转换为数据类型 int 的算术溢出错误”
【发布时间】:2011-10-07 12:31:58
【问题描述】:

我正在尝试执行我的简单 SQL 代码来创建一个表。

BEGIN TRANSACTION;
CREATE TABLE vlan (vlanId int, vlanValue varchar(250), vlanName varchar(250), portId int, portName varchar(250), nodeId int, nodeName varchar(250));
INSERT INTO vlan VALUES(1111,998,'VOICE',7272,'1/97',456439345,'10.2.2.2');
.
.
.
.
INSERT INTO vlan VALUES(923482342,240,'INFODESK',2348328434,'4/46',2349234234,'10.1.2.3');
COMMIT;

它给出了错误:

Msg 8115, Level 16, State 2, Line 16164
Arithmetic overflow error converting expression to data type int.
The statement has been terminated.
Msg 8115, Level 16, State 2, Line 16165
Arithmetic overflow error converting expression to data type int.
The statement has been terminated.
Msg 8115, Level 16, State 2, Line 16166
Arithmetic overflow error converting expression to data type int.
The statement has been terminated.

这张桌子大约有。 16500 个元素。是不是文件太大了?

任何帮助都会很有用。

【问题讨论】:

    标签: sql types sql-server-2008


    【解决方案1】:

    对于数据类型 int(-2147483647 到 2147483647),您的 vlanId 列太大了。 使用bigInt

    链接到SQL Server Doc.

    【讨论】:

      【解决方案2】:

      来自 MSDN - int, bigint, smallint, and tinyint (Transact-SQL):

      int

      从 -2^31 (-2,147,483,648) 到 2^31 - 1 (2,147,483,647) 的整数(整数)数据。存储大小为 4 个字节。 int 的 SQL-92 同义词是整数。

      您尝试插入的值 (2348328434) 在这些值之外。请改用bigint

      【讨论】:

        猜你喜欢
        • 2023-03-15
        • 1970-01-01
        • 1970-01-01
        • 2022-01-02
        • 1970-01-01
        • 2014-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多