troubleshooting Question

Stored procedure - Iterate result set.

Avatar of jfsedlar3rd
jfsedlar3rdFlag for United States of America asked on
Microsoft SQL ServerMySQL Server
1 Comment1 Solution2430 ViewsLast Modified:
I have the following stored proc that returns a result set of Its. How can I iterate through that result set and perform an update statement on each record for the current ID or on all of them at once. The update will be the same for each ID so it really doesnt matter. This is what i have so far:

-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
CREATE PROCEDURE Participants_proc
      -- Add the parameters for the stored procedure here
      @partlst  nvarchar(1000)
      @entryID int
AS
BEGIN
DECLARE @ID int
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;

    -- Insert statements for procedure here
SELECT @ID = ID FROM WOW_Participants WHERE entryID = @entryID AND empID NOT IN (@partlst)

END
GO
ASKER CERTIFIED SOLUTION
strickdd

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros