Answer Posted / praveen singh
A cursor is a set of rows together with a pointer that
identifies a current row.
In other word, Cursor is a database object used by
applications to manipulate data in a set on a row-by-row
basis, its like recordset in the ASP and visual basic.
DECLARE @fName varchar(50), @lName varchar(50)
DECLARE cursorName CURSOR -- Declare cursor
LOCAL SCROLL STATIC
FOR
Select firstName, lastName FROM myTable
OPEN cursorName -- open the cursor
FETCH NEXT FROM cursorName
INTO @fName, @lName
PRINT @fName + ' ' + @lName -- print the name
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM cursorName
INTO @fName, @lName
PRINT @fName + ' ' + @lName -- print the name
END
CLOSE cursorName -- close the cursor
DEALLOCATE cursorName -- Deallocate the cursor
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
What is the Main Difference between ACCESS and SQL SERVER?
What is single-user mode and what are the steps you should follow to start sql server in single-user mode?
What happens if you delete a table that is used by a view?
What are pessimistic lock and optimistic lock?
what changed between the previous version of sql server and the current version? : Sql server database administration
What is the current pricing model of SQL Azure?
can an order by clause be used in a creation of a view?
Why use sub query in sql server and list out types of sub queries?
What is delete query?
How ssrs maintain security?
How will you add a dimension to cube? : sql server analysis services, ssas
How to optimize stored procedures in sql server?
List out some of the requirements to set up a sql server failover cluster?
Can an entity have two primary keys?
How to create function without parameter in sql server?