How to automatically reseed after using identity_insert?

Posted by Earlz on Stack Overflow See other posts from Stack Overflow or by Earlz
Published on 2010-05-27T18:35:42Z Indexed on 2010/05/27 18:41 UTC
Read the original article Hit count: 145

Hello, I recently migrated from a PostgreSQL database to a SQL Server database. To switch the data over I had to enable IDENTITY_INSERT. Well come to find out that I get all sorts of strange errors due to duplicate identity values(which are set as primary keys) upon doing an insert in any of the tables.

I have quite a few tables. What would be the easiest way of automatically reseeding the identity of every table so that it is after max(RID)?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about Identity