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
List the ways in which dynamic sql can be executed?
how would you store your query in an SSRS report or a Database server?
what is the maximum size of a row? : Sql server database administration
Can we return Data from 4(more than 1) tables in stored procedure?
Why should one not prefix user stored procedures with ‘sp_’?
hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.
In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram
How do you make a trace?
What are the differences between user defined functions and stored procedures?
What are unicode character string data types in ms sql server?
What is a join in sql? What are the types of joins?
What are the difficulties faced in cube development? : sql server analysis services, ssas
Name three of the features managed by the surface area configuration tool? : sql server security
Do you know what are the reporting services components?
Explain sql server authentication modes?