TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abraham Olatubosun
NA
471
113.6k
How to Perform Multiple Task in T-SQL
Jul 26 2017 5:32 PM
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
Reply
Answers (
2
)
Additional information: Conversion failed when converting th
while loop is not working in sql server 2012