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
there is a trigger defined for insert operations on a table, in an oltp system. The trigger is written to instantiate a com object and pass the newly inserted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? : Sql server database administration
Mention the command used to rename the database.
Define full outer join?
What’s the use of custom fields in report?
What do you understand by triggers and mention the different types of it?
How connect excel to sql server?
What are scalar functions?
Where is localdb stored?
what are the different types of SSRS reports?
Explain what are magic tables in sql server?
What languages bi uses to achieve the goal?
What is the default Port No on which SQL Server listens?
What is SQL Azure Federations?
When you use @@error and try-catch?
How to find the list of fixed hard drive and free space on server?