I have to run stored procedure based on the query - I've done it using cursor, but as I can see from the forum postings - cursor is bad.
Can you help me on how I can reach the same result without using cursor?
create proc stp_completAllAttendee
@classID int
as
Declare firstQuery Cursor for
SELECT loginName
FROM tblClassAttendee
where classID = @classID
for Read Only;
Declare @analystLogin char(10);
Open firstQuery;
Fetch Next from firstQuery Into @analystLogin;
WHILE (@@fetch_status <> -1)
BEGIN
EXEC stp_AttendeeComplete @classID, @analystLogin;
Fetch Next from firstQuery Into @analystLogin;
END;
close firstQuery;
deAllocate firstQuery;
GO
Can you help me on how I can reach the same result without using cursor?
create proc stp_completAllAttendee
@classID int
as
Declare firstQuery Cursor for
SELECT loginName
FROM tblClassAttendee
where classID = @classID
for Read Only;
Declare @analystLogin char(10);
Open firstQuery;
Fetch Next from firstQuery Into @analystLogin;
WHILE (@@fetch_status <> -1)
BEGIN
EXEC stp_AttendeeComplete @classID, @analystLogin;
Fetch Next from firstQuery Into @analystLogin;
END;
close firstQuery;
deAllocate firstQuery;
GO