, , "" IDENTITY, - IDENTITY. (SQL Server 2008):
CREATE TABLE Test
(
ID INTEGER IDENTITY(1, 1) NOT NULL,
data_col INTEGER NOT NULL
);
INSERT INTO Test (data_col)
VALUES (1), (2), (3), (4);
DELETE
FROM Test
WHERE ID BETWEEN 2 AND 3;
DBCC CHECKIDENT ('Test', RESEED, 1)
INSERT INTO Test (data_col)
VALUES (5), (6), (7), (8);
SELECT T1.ID, T1.data_col
FROM Test AS T1
ORDER
BY data_col;
:
ID data_col
1 1
4 4
2 5
3 6
4 7
5 8
This shows that not only the “holes” are filled with new automatically generated values, values that were automatically generated before being copied again, and may even duplicate existing IDENTITY values.
source
share