Advertisement
imjyb1008work

MS SQL CURSOR Cheat sheet

Aug 1st, 2018
1,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.26 KB | None | 0 0
  1. DECLARE MYCURSOR CURSOR FOR {{Your Table}}
  2. OPEN MYCURSOR
  3.     FETCH NEXT FROM MYCURSOR INTO {{Your parameter}}
  4.     WHILE @@FETCH_STATUS = 0 BEGIN
  5.  
  6.         --- Do Something
  7.        
  8.         FETCH NEXT FROM MYCURSOR INTO {{Your parameter}}
  9.     END
  10. CLOSE MYCURSOR
  11. DEALLOCATE MYCURSOR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement