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

List the ways in which dynamic sql can be executed?

1012


how would you store your query in an SSRS report or a Database server?

162


what is the maximum size of a row? : Sql server database administration

1005


Can we return Data from 4(more than 1) tables in stored procedure?

1053


Why should one not prefix user stored procedures with ‘sp_’?

1036


hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.

2065


In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram

2005


How do you make a trace?

1015


What are the differences between user defined functions and stored procedures?

1063


What are unicode character string data types in ms sql server?

1242


What is a join in sql? What are the types of joins?

1093


What are the difficulties faced in cube development? : sql server analysis services, ssas

1036


Name three of the features managed by the surface area configuration tool? : sql server security

986


Do you know what are the reporting services components?

971


Explain sql server authentication modes?

1123