I am getting the error as
"The INSERT statement conflicted with the FOREIGN KEY constraint "FK_studentstudentcourse". The conflict occurred in database "Joins", table "dbo.student", column 'Roll_no'."
during inserting the details into studentinfo table.
create table student(
Roll_no int IDENTITY(1,1) PRIMARY KEY,
name varchar(255),
address varchar(255)
)
insert into student values('harsh','bangalore');
insert into student values('pratik','bangalore');
insert into student values('riyanka','bangalore');
insert into student values('deep','bangalore');
insert into student values('saptari','bangalore');
insert into student values('dhanraj','bangalore');
insert into student values('rohit','bangalore');
insert into student values('niraj','bangalore');
insert into student values('harsh','bangalore');
create table studentcourse(
Courseid int NOT NULL,
Roll_no int,
PRIMARY KEY (Courseid),
CONSTRAINT FK_studentstudentcourse FOREIGN KEY (Roll_no)
REFERENCES student(Roll_no)
)
insert into studentcourse values(1,1)
insert into studentcourse values(2,2)
insert into studentcourse values(2,3)
insert into studentcourse values(3,4)
insert into studentcourse values(1,5)
insert into studentcourse values(4,9)
insert into studentcourse values(5,10)
insert into studentcourse values(4,11)