5.5. SYNTAX AND EXAMPLE

 

SYNTAX To DECLARE CURSER:-

declare @eid int

declare @name varchar(30)

declare empcursor cursor for

select emp_id,f_name from emp


SYNTAX TO OPEN CURSER:-

open empcursor


SYNTAX TO FETCH CURSER:-

fetch next from empcursor into @eid, @name

while(@@FETCH_STATUS=0)

Begin

print 'id=' + cast(@eid as varchar(10)) + 'name=' + @name

fetch next from empcursor into @eid, @name

end


SYNTAX TO CLOSE CURSER:-

CLOSE empcursor


SYNTAX TO DEALLOCATE CURSER:-

DEALLOCATE empcursor



Last modified: Tuesday, 17 December 2019, 5:22 PM