Pregunta

Assuming I have a table with many hundreds of rows (10,000) and I delete rows with Id 500 -> 5,000.

What would happen if I reseed the Id column to 500 when I insert 4,501 new rows?

Is Microsoft SQL server cleaver enough to assign the id 10,001 to the final item I insert, or will it get stuck?

¿Fue útil?

Solución

SQL will stuck and insert will fail; also Microsoft doesn't recommend to reseed with a new values witch is less than current.

You might want to copy your data into temp table; truncate (this will reseed value to 0) and insert it back - that will close the gap.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top