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?

Answers were Sorted based on User's Feedback



what is a cursor and what is its use?..

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

what is a cursor and what is its use?..

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

Post New Answer

More SQL Server Interview Questions

What is measure group, measure? : sql server analysis services, ssas

0 Answers  


Can two different columns be merged into single column? Show practically?

0 Answers   QuestPond,


What is difference between clustered and non clustered index?

0 Answers  


what is a major difference between sql server 6.5 and 7.0 platform wise? : Sql server database administration

0 Answers  


Explain candidate key, alternate key, and composite key?

0 Answers  


If you are given access to a SQL Server, how do you find if the SQL Instance is a named instance or a default instance?

0 Answers  


Explain “@@rowcount” and “@@error” in sql server?

0 Answers  


How to use order by with union operators in ms sql server?

0 Answers  


What are policy management terms?

0 Answers  


Can a cursor be updated? If yes, how you can protect which columns are updated?

0 Answers  


How to execute the cursor queries with "open" statements?

0 Answers  


What are the advantages of user-defined functions over stored procedures in sql server?

0 Answers  


Categories