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 in SQL Server 2000 and their types?

Answer Posted / vasanthi

When will be use cursor need to perform following steps:-

1. DECLARE CURSOR

2. OPEN

3. FETCH

4. @@FETCH_STATUS

5. CLOSE

6. DEALLOCATE


1.DECLARE cursor_name CURSOR FOR SELECT_statement;

2.OPEN cursor_name;

3.FETCH cursor_name INTO variable list;

5.CLOSE cursor_name;

5.DEALLOCATE cursor_name;


sample
******

DECLARE Employee_Cursor CURSOR FOR
SELECT LastName, FirstName
FROM AdventureWorks2008R2.HumanResources.vEmployee
WHERE LastName like 'B%';

OPEN Employee_Cursor;

FETCH NEXT FROM Employee_Cursor;
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM Employee_Cursor
END;

CLOSE Employee_Cursor;
DEALLOCATE Employee_Cursor;

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between implicit and explicit transaction?

991


Explain error and transaction handling in sql server?

990


What is the difference between indexing and hashing?

1140


Explain following error properties?

994


What is the significance of master, tempdb and model databases?

1063


Why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it?

856


Explain some stored procedure creating best practices or guidelines?

905


How does stuff differ from the replace function?

989


What the different topologies in which replication can be configured?

1066


How can you know if the row fetched from cursor is still valid in underlying table?

984


what is a join and explain different types of joins? : Sql server database administration

939


what is unique and xaml nonclustered index

1027


What is named query? : sql server analysis services, ssas

940


What are the limitations in ssrs on sql server express edition?

186


Explain nested trigger in sql?

1050