I am creating a database table with an index number (CustRef
) for each row.
The index starts from 1 and increases 1 with each new row. The query language as followed:
CREATE TABLE [dbo].[CustDetails]
(
[CustRef] [int] IDENTITY(1,1) NOT NULL,
[LName] [nchar](25) NOT NULL,
[FName] [nchar](25) NOT NULL,
[Address] [nchar](80) NULL,
[Suburb] [nchar](25) NULL,
[State] [nchar](5) NULL,
[PCode] [nchar](5) NULL,
CONSTRAINT [PK_CustDetails]
PRIMARY KEY CLUSTERED ([CustRef] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
The table is created successfully and I was testing it by inserting some sample data. At one stage, I deleted a row, which the index number (CustRef
) was 6. After I deleted index 6 row and continue inserting sample data.
Unfortunately, the index number is not consecutive. In other word, I was expecting the new data content will use the index 6 as its row index number. However, new entries skip index 6, it starts from index 7.
As you can see from the above screenshot, between index 5 and 7, index 6 is missing.
How to resolve this issue? Thanks in advance.