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
Explain how to use linked server?
Explain triggers?
What are the database objects? : SQL Server Architecture
Do you know how to send email from database?
What is a primary key?
What is the guest user account in sql server? What login is it mapped to it? : sql server security
What are the difficulties faced in cube development? : sql server analysis services, ssas
What are synonyms?
How to enable tcp/ip protocol on a sql server?
What is the use of keyword with encryption. Create a store procedure with encryption?
there is a trigger defined for insert operations on a table, in an oltp system. The trigger is written to instantiate a com object and pass the newly inserted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? : Sql server database administration
Which joins are sql server default?
What do you mean by a Composite primary key?
What are the different acid properties?
What’s the distinction between dropping a info and taking a info offline?