Greetings, can someone please give me an idea on how to make a stored procedure with foreign key. Here's what i want to happen.
1) I have 1 button for Adding patient.
2) On the add patient button, i want to Add the patient information on the tblPatient and insert the p_ID on the tblRecord.
2) After i add it on the tblPatient, the p_ID should also go to the tblRecord.
`@patientFname varchar(60), @patientIname varchar(20), @patientLname varchar(50),
@patientHaddress varchar(100), @patientPaddress varchar(50), @Dob date, @gender varchar(10), @contactNo varchar(10), @p_ID int,
@tCount varchar(5), @details varchar(50)
AS
INSERT INTO tblPatient(patientFname,patientIname,patientLname,patientHaddress,patientPaddress,Dob,gender,contactNo)
VALUES(@patientFname, @patientIname, @patientLname, @patientHaddress, @patientPaddress, @Dob, @gender, @contactNo)
SELECT p_ID = SCOPE_IDENTITY()
INSERT INTO tblRecord (p_ID, tCount, details)
VALUES (@p_ID, @tCount, @details)`