Posted By

simi23 on 01/11/12


Tagged

mssql loop PLSQL cursor


Versions (?)

MSSQL Cursor


 / Published in: PL/SQL
 

basic definition for a cursor in MSSQL

  1. DECLARE myCursor CURSOR local fast_forward FOR
  2. SELECT col001, col002, col003 FROM DataTable
  3. OPEN myCursor
  4. FETCH next FROM myCursor INTO @var1, @var2, @var3
  5. IF @@FETCH_STATUS <> 0 break
  6.  
  7. print 'The variable values are: ' + @var1 + ', ' + @var2 + ' and ' + @var3
  8.  
  9.  
  10. CLOSE myCursor
  11. deallocate myCursor

Report this snippet  

You need to login to post a comment.