View Single Post
  #7 (permalink)  
Old 01-06-09, 12:43
tomh53 tomh53 is offline
9th inning DBA
 
Join Date: Jan 2004
Location: In a large office with bad lighting
Posts: 1,036
That is not a valid cursor. The cursor declaration select the columns. The fetch assigns them to the variables.

Code:
DECLARE overdue_cursor CURSOR FOR 
SELECT dbo.tblUsers.user_email, dbo.tblActions.acti_notes, dbo.tblActions.acti_subject
FROM dbo.tblActions
INNER JOIN dbo.tblUsers ON dbo.tblActions.acti_user_id = dbo.tblUsers.user_id
WHERE (dbo.tblActions.acti_complete = 0) AND (dbo.tblActions.acti_due_datetime IS NOT NULL) AND (dbo.tblActions.acti_due_datetime > GETDATE())
 
OPEN overdue_cursor
FETCH NEXT FROM overdue_cursor into @email, @notes, @subject
WHILE @@FETCH_STATUS = 0
BEGIN
   <processing steps>
   FETCH NEXT FROM overdue_cursor into @email, @notes, @subject
END
 
CLOSE CURSOR overdue_cursor
 
DEALLOCATE overdue_cursor
__________________

-- This is all just a Figment of my Imagination --
Reply With Quote