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
In what three ways is the return statement used in a stored procedure?
Tell me what is sql profiler?
What is shared lock?
What is rolap and its advantage? : sql server analysis services, ssas
Can I run multiple instances of sql server 2000 at the same time on one computer?
How to convert numeric expression data types by assignment operations?
What is abstracting periodical?
What happens if the update subquery returns multiple rows in ms sql server?
Can a synonym name of a table be used instead of a table name in a select statement?
How to join two tables in a single query in ms sql server?
Explain the use of containers in ssis?
What does it mean to normalize a database and why would you do it?
What does it mean to be in union?
How to verify a user name with sqlcmd tool?
What is after dml trigger?