Asp.net Form
Student Name
Student Address
English (marks)
Maths (marks)
Science (marks)
For the above form I have created the following table structure
Create Table Student
(
sId int primary key identity(100,1),
sName varchar(50),
sAddress varchar(100)
)
Create Table Subjects
(
subId int primary key,
subName varchar(100)
)
Create Table Marks
(
mid int primary key identity(1,1),
sId int foreign key references Student(sId) ,
subId int foreign key references Subjects(subId),
MarkPercent int
)
Create Procedure uspAddStudentDetails
(
@sName varchar(50),
@sAddress varchar(100),
@English int,
@Maths int,
@Science int
)
AS
Begin
Insert into Students (sName, sAddress) values (@sName, @sAddress)
End
I would like to create a stored procedure to insert once into the Student
table then insert multiple details into the Marks
table as mentioned below. I tried to some extent in the above SP.
Subjects
1000 English
2000 Maths
3000 Science
Student
100 #10,Madison Rd.
Marks
1 100 1000 90
2 100 2000 76
3 100 3000 80
I think the below Procedure Suits your requirements:
First Insert this Value
Use this Procedure:
And Execute the Procedure:
Output in
Student
table:Marks
Table: