SQL Reseed Identity

If you need to manually insert a value into an identity column, but you don't want to interrupt the current identity sequence, you can reseed the value.

If you go with a positive value, make sure you pick something higher than you'll ever hit, to avoid an ID collision.

Or you can pick a negative number instead. This also gives you the advantage of picking a smaller meaningful number, and easy recognition that this ID is special. Also, if you go negative, you don't need to even both with reseeding the identity.

View Code on GitHub

Comments

Popular posts from this blog

C# Record Serialization

Add timestamp to photo using ImageMagick

Read/write large blob to SQL Server from C#