Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identity Columns

I've an identity column which has multiple deletes now it is not working because it reaches the max limit of the INT data type, how can I insert records in the place of deleted ones without truncating all the data?

like image 624
Hadad Avatar asked Dec 19 '25 17:12

Hadad


1 Answers

You cannot "recycle" unused IDENTITY values - if you've reached the end of the INT data range, you need to change your ID column to BIGINT.

ALTER TABLE dbo.YourTable
  ALTER COLUMN YourIDColumn BIGINT

The IDENTITY property will be preserved - now you have a lot of additional ID values available for the next couple months/years to come!

like image 157
marc_s Avatar answered Dec 23 '25 08:12

marc_s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!