Hello Friend,
can u send me about cursor? i find it most difficult.
What is cursor? How many Types of cursor? how to create each one?
what r the benefit of each cursor?
Cursors are special programming constructs that allow data to be manipulated on a row-by-row basis, similar to other structured programming languages. They are declared like a variable, and then move one record at a time using a loop for control. There are three types of cursors, DYNAMIC, STATIC, and KEYSET. There are also three types of locks for cursors, READ ONLY, SCROLL LOCKS, and OPTIMISTIC.
Benefit - Featch more records at time for that purpose you can use Cursor.
Eg:
USE pubs
GO
DECLARE get_price CURSOR FOR
SELECT price FROM titles
OPEN get_price
FETCH NEXT FROM get_price
WHILE @@FETCH_STATUS = 0
FETCH NEXT FROM get_price
CLOSE get_price
DEALLOCATE get_price