Store procedure problem

Results 1 to 2 of 2

Thread: Store procedure problem

  1. #1
    Join Date
    Dec 1969

    Default Store procedure problem

    Hi, <BR><BR>sorry I have to post this again in Advanced section as I didn&#039;t get any response in the ASP Q&A section.<BR><BR>I am trying to update the status of all the records in the table but when I tested it only the first record was updated. Is it something to do with the fetch statement? where did it go wrong? (this is only a simplied version of what I am trying to do so it must be done in this way as I am actually trying to loop through all records to send out emails to all users with specified status) <BR><BR>section of the code in the stored procedure : <BR><BR><BR>DECLARE topcur CURSOR FOR <BR>SELECT STATUS <BR> FROM tb_testing order by UID <BR><BR><BR>OPEN topcur <BR><BR>FETCH topcur INTO @status <BR><BR>WHILE @@FETCH_STATUS = 0 BEGIN <BR><BR> UPDATE tb_testing <BR> SET STATUS = 1 <BR> WHERE CURRENT OF topcur <BR><BR><BR><BR><BR> END <BR><BR> CLOSE topcur <BR> DEALLOCATE topcur <BR><BR>Many thanks <BR><BR>James

  2. #2
    Join Date
    Dec 1969

    Default Go read my other response...

    ...but I don&#039;t see here where you advance the cursor inside the loop. You did better than that in the actual problem.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts