5

Arithmetic overflow error converting IDENTITY to data type int, is occurring when running through vb code. But when I execute the stored procedure, data gets inserted properly.

Through application also sometimes this works and sometimes it doesn't.

When I check the current identity value and current column values are different. IS this falls under issue.

Please let me know how to solve it.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

5 Answers5

6

Please DO NOT use

DBCC CHECKIDENT('dbo.TableName',reseed,0)
//or 
DBCC CHECKIDENT('dbo.TableName')

to troubleshoot this like I did. It will cause the database to re-set your identities.

Please use this

DBCC CHECKIDENT('dbo.TableName',NORESEED)

It will show if your table is at the maximum for int values. The maximum for int is 2,147,483,647.

Dilan
  • 2,610
  • 7
  • 23
  • 33
user3407335
  • 106
  • 1
  • 6
3

2147483647 Is the maximum size for INT so somewhere your IDENTITY is larger than this. You can use BIGINT instead to get around your error, assuming your IDENTITY won't surpass 9223372036854775807.

S3S
  • 24,809
  • 5
  • 26
  • 45
  • It didn't crossed maximum INT value. The data is coming from MQ.. I stopped MQ connection after some time data get processed. After it came to 0. i connected it again shows same error. i noticed current column value and current identity value are different, some times those two are becoming same. I am assuming that flow is happening when both are same. – Sandeep Kumar Reddy Bade Aug 02 '16 at 04:49
1

Like others have said, your column is greater than the range allowed for the type.

You could reseed using DBCC CHECKIDENT('dbo.TableName',reseed,0) like others have said, but that could cause errors if you attempt to reuse a value that has already been used.

Assuming the column is an auto increment identity column and your row count is lower than the data type range, you could reinsert all of the values.

  1. Create a backup table
  2. Insert all entries in to backup table
  3. Truncate original table
  4. Insert all entries from backup table
  5. Drop backup table

This will depend on your constraints and may be more difficult than it is worth.

0

you can use this:

DBCC CHECKIDENT('dbo.TableName',reseed,0)

it reseed to 0.

-1

which version of VB are you using? Are you using variable type 'long' to up the returned value in ? In VB 6 and before int is very limited in values, and in .net it is still limited to include only some 10 digit numbers.

I would make sure you are using 'long' in VB

Cato
  • 3,652
  • 9
  • 12