开发者

"Arithmetic overflow error converting expression to data type int"

I'm trying to execute my simple SQL code to create a table.

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;

it gives the error:

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.

The table has approx. 16500 elements. Is it because the file is too large?

Any help will be useful.


Your vlanId column is to big for the datatype int (-2147483647 to 2147483647). Use bigInt.

Link to SQL Server Doc.


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

int

Integer (whole number) data from -2^31 (-2,147,483,648) through 2^31 - 1 (2,147,483,647). Storage size is 4 bytes. The SQL-92 synonym for int is integer.

The value you are trying to insert (2348328434) is outside of these. Use bigint instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜