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
Define msdb database?
What is sql server profiler trace data file?
Explain about builtinadministrator?
Tell me the use of keyword with encryption. Create a store procedure with encryption?
How to skip remaining statements in a loop block using continue statements?
How to restore performance issues and how to check?
Why and when do stored procedure recompile?
What are the advantages of user-defined functions over stored procedures in sql server?
Write a query to include a constraint, to check whether the employee salary is greater than 5000?
What are drillthrough reports?
How to get a list of columns using the "sys.columns" view in ms sql server?
how do you determine the Load performance of any query in sql server {example how do u determine performance of a select stmnt which returns Dynamically many no of records ... some times 100,1000,10000 etc., }
What is a livelock?
What is the difference between commit and rollback?
What is the difference between a unique key and primary key?