what is a cursor and what is its use?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / ramesh
when we execute any query its return result set. directly
to work on result set we use cursors.
but right now no one is supporting cursors.
Is This Answer Correct ? | 3 Yes | 0 No |
Can we use where clause with group by?
What is the difference between in and exists. Ex: select * from emp where empno in(....) and select * from emp where empno exists(....) What is the difference between a Join and Union and Union and UnionAll.
How to create hyperlink from returned sql query ?
What type of locking occurs during the snapshot generation? : sql server replication
List all the types of user-defined functions?
Give some Scenario for Non Clusterd index? Can we write system defined functions in side The Function? Wat is the Unique Datatype?
Why Master database is required?
Can group by be used without aggregate functions?
What is the difference between varchar and nvarchar?
What are the instances when triggers are appropriate?
What is a fill factor?
What is sql server locking?