Larry Brister
asked on
Fetch statement skewed
My code below works, but @id is never changed.
DECLARE @id int
DECLARE @htid VARCHAR(1000)
SET @htid = '71886,71887,71888,71889'
DECLARE htid_cursor CURSOR FOR
SELECT [str] FROM dbo.Parselist(@htid,',')
OPEN htid_cursor;
FETCH NEXT FROM htid_cursor
INTO @id;
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
-- This is executed as long as the previous fetch succeeds.
INSERT INTO [dbo].[EmailQueue]
( [Application] ,
[FromLine] ,
[ToLine] ,
[Subject] ,
[MessageSource]
)
VALUES
( 'Test' , -- Application - varchar(255)
'noreply@nightingalenurses.net' , -- FromLine - varchar(3000)
'lbrister@nightingalenurses.net' , -- ToLine - varchar(3000)
'Test Insert' , -- Subject - varchar(max)
@id
);
FETCH NEXT FROM htid_cursor;
END
CLOSE htid_cursor;
DEALLOCATE htid_cursor;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh man...THAT'S embarrassing!
Thanks