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)
the above code works, i want to use the PTN_PK to update tbl_ARTSTARTDATE_TABE based on the crateria specied as shown below :
- 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)
I want all the commands to be in one Stored Procedure.
Thank you all