Dear Code Masters,
Hope this mail meet you all in good health. Please i will aprecaite any workable solution to my question.
I want to create a single store procedure that i want to INSERT to a table based on some crateria, after then use this table new record to update itself based on other crateria
E.g :
- use IQCARE
- INSERT INTO tbl_ARTSTARTDATE_TABLE (ptn_pk,PatientID,HospitalNumber,Sex,AgeAtStartART,DOB,ARTStartDate,ArtStatus )
- (select ptn_pk,PatientID,HospitalNumber,Sex,AgeAtStartART,DOB,ARTStartDate,ArtStatus from tbl_RADET_TABLE)
- UPDATE tbl_ARTSTARTDATE_TABLE a SET LastPickupDate =(Select top 1 DispensedByDate from VW_PatientPharmacy b Where b.Ptn_pk =a.Ptn_pk
- and DispensedByDate is not null order by DispensedByDate desc)
Thank you all

Gokhul VarmanPosted Aug 5, 2017, 10:14 AM
jude somtooPosted Jul 28, 2017, 10:29 PM
(
@studentid int output,
@imageurl nvarchar(250),
@fullname nvarchar(10),
@email nvarchar(100),
@gender nchar(10),
@Department nvarchar(50),
@faculty nvarchar(50),
@regno int,
@address nvarchar(250),
@modeofstudy nvarchar(50),
@dateofadmission nchar(50),
@programmeofstudy nvarchar(50)
)
as
insert into acceptance(imageurl,fullname,email,gender,Department,faculty,regno,[address],modeofstudy,dateofadmission,programmeofstudy)
values(@imageurl,@fullname,@email,@gender,@Department,@faculty,@regno,@address,@modeofstudy,@dateofadmission,@programmeofstudy)
(
@studentid int output,
@imageurl nvarchar(250),
@fullname nvarchar(10),
@email nvarchar(100),
@gender nchar(10),
@Department nvarchar(50),
@faculty nvarchar(50),
@regno int,
@address nvarchar(250),
@modeofstudy nvarchar(50),
@dateofadmission nchar(50),
@programmeofstudy nvarchar(50)
)
as
update acceptance set imageurl = @imageurl, fullname = @fullname, email = @email, gender = @gender,dateofadmission = @dateofadmission,
Department = @Department, faculty = @faculty, regno = @regno, [address] = @address,modeofstudy = @modeofstudy,programmeofstudy=@programmeofstudy
where studentid = @studentid;