Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
How to Perform Multiple Task in T-SQL
Abraham Olatubosun
Jul 26 2017 5:32 PM
257
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Additional information: Conversion failed when converting th
while loop is not working in sql server 2012