-- sybase-cursor -- template for using a cursor -- $Id$ -- Carlos Duarte , 000721 -- code to snip into stored procedure / plain transact-sql use DB go declare c1 cursor for select x1,x2 from tbl_y where 1=1 for read only go declare @z1 varchar(30) declare @z2 varchar(30) -- ... open c1 while 1 = 1 begin fetch c1 into @z1,@z2 if @@sqlstatus != 0 break -- rest of sql code end deallocate cursor c1 go