Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is a cursor and what is its use?

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


Please Help Members By Posting Answers For Below Questions

What is the Main Difference between ACCESS and SQL SERVER?

1067


What is single-user mode and what are the steps you should follow to start sql server in single-user mode?

936


What happens if you delete a table that is used by a view?

943


What are pessimistic lock and optimistic lock?

1000


what changed between the previous version of sql server and the current version? : Sql server database administration

957


What is the current pricing model of SQL Azure?

104


can an order by clause be used in a creation of a view?

1102


Why use sub query in sql server and list out types of sub queries?

940


What is delete query?

898


How ssrs maintain security?

1018


How will you add a dimension to cube? : sql server analysis services, ssas

1013


How to optimize stored procedures in sql server?

1125


List out some of the requirements to set up a sql server failover cluster?

981


Can an entity have two primary keys?

927


How to create function without parameter in sql server?

993