Examples Using "WHERE CURRENT OF"

  • I open a cursor and loop through the records. I wanted to update one record that I am fetching. I checked the BOL and read about the "WHERE CURRENT OF" clause but had not had much success with it.

    Did anyone use this before? I appreciate your sharing with me some examples.

  • Declare your cursor as follows

    
    
    USE PUBS
    DECLARE @lName varchar(40)

    DECLARE crsMyCursor CURSOR FOR
    SELECT au_lname FROM AUTHORS

    OPEN crsMyCursor

    FETCH NEXT FROM crsMyCursor INTO @lName

    UPDATE Authors SET au_lname = 'Hello World' WHERE CURRENT OF crsMyCursor

    CLOSE crsMyCursor
    DEALLOCATE crsMyCursor
  • THANK YOU!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply