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

In what three ways is the return statement used in a stored procedure?

1006


Tell me what is sql profiler?

1026


What is shared lock?

901


What is rolap and its advantage? : sql server analysis services, ssas

1281


Can I run multiple instances of sql server 2000 at the same time on one computer?

1072


How to convert numeric expression data types by assignment operations?

1074


What is abstracting periodical?

944


What happens if the update subquery returns multiple rows in ms sql server?

1123


Can a synonym name of a table be used instead of a table name in a select statement?

1028


How to join two tables in a single query in ms sql server?

991


Explain the use of containers in ssis?

963


What does it mean to normalize a database and why would you do it?

979


What does it mean to be in union?

931


How to verify a user name with sqlcmd tool?

1078


What is after dml trigger?

1011