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
Explain the categories of stored procedure i.e. System stored procedure, local stored procedure, temporary stored procedure, extended stored procedure, remote stored procedure?
What are the authentication modes in sql server? How can it be changed?
What is right outer join in sql server joins?
Explain having clause?
Tell me the use of keyword with encryption. Create a store procedure with encryption?
Will count(column) include columns with null values in its count?
What is row_number () and partition by in sql server?
Define union, union all, minus, intersect?
What are the different normalization forms?
Why do you want to join software field as you have done your BE in Electronics?
What is raid and what are different types of raid levels?
How to select all columns of all rows from a table with a select statement in ms sql server?
What is an identity?
Why use sub query in sql server and list out types of sub queries?
I applied Transactional with updatable subscriptions replication on 2 tables now i want to delete those 2 tables but i cannot delete those tables as replication is running how can i stop replication for those 2 tables(but i don't want to delete those replicated tables but i need to stop the replication) how can i do that