In SQL Server Management Studio I created several tables and in id I used identity(1,1)
with constraint primary key clustered Id asc
. When I was insert values in tables and after that I saw the column with id in every table starting with another number like 8, 5, 9 etc, but not with 1 as it should be. I didn't have this problem before. Is it possible because first I connected tables with foreign key and after that I started to insert values? Here is the code:
create table [dbo].[Semester]
(
[Id] [int] identity(1,1) not null,
[Semester] [tinyint] null,
[StartDay] [date] not null,
[EndDate] [date] not null,
constraint [PK_Semester]
primary key clustered ([Id] asc)
)
go
insert into [dbo].[Subject] ([Name], [Days])
values ('Intro in programming', 20)
and the result is:
Id | Name | Days | SemesterId | |
---|---|---|---|---|
1 | 4 | Intro in programming | 20 | null |
I don't have insert value in SemesterId
because in that table like in every tables is the same problem and have exception doesn't match with Id
in Semester table with SemesterId
, because in Semester table column Id
is 6 and whenever I delete them and re-create them, Id
's has difference numbers, but not start from 1 and doesn't ascending in order.