Posted By

RealRover on 08/05/10


Tagged

cursor


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Using CURSOR


 / Published in: SQL
 

  1. DECLARE @Id INT
  2.  
  3. DECLARE id_cursor CURSOR FOR
  4. SELECT Id
  5. FROM TableName
  6.  
  7. OPEN id_cursor
  8.  
  9. FETCH NEXT FROM id_cursor INTO @Id
  10.  
  11. WHILE @@FETCH_STATUS = 0
  12. BEGIN
  13.  
  14. /* Code here */
  15.  
  16. FETCH NEXT FROM id_cursor INTO @Id
  17. END /* WHILE @@FETCH_STATUS = 0 for @Id */
  18.  
  19. CLOSE id_cursor
  20. DEALLOCATE id_cursor

Report this snippet  

You need to login to post a comment.