Question : Update Query on fetch

My attached code works great.

But I would like to run this update query on each record as the email is send.

UPDATE PORTAL.dbo.zTestEmails SET SENT = 'True' where emailaddress = @email
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
SET QUOTED_IDENTIFIER OFF  
  
declare @email varchar(100)  
declare @subject varchar(255)
declare @body varchar(4000)  

DECLARE EMAIL cursor for  
      select EmailAddress, subject,html  
      from PORTAL.dbo.zTestEmails
      where sent = 'False'  
  
     FOR READ ONLY  
  
OPEN Email  
  
FETCH NEXT FROM Email into @email, @subject, @body
WHILE @@FETCH_STATUS = 0  
BEGIN  
     
exec dbo.sp_portal_SendNotificationEmail @email, @subject, @body


    FETCH NEXT FROM Email into @email, @subject, @body
END  
CLOSE Email  
DEALLOCATE Email

Answer : Update Query on fetch

so? add that code after exec...
Random Solutions  
 
programming4us programming4us