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
What is a partition function in sql server?
How do you troubleshoot errors in a SQL Server Agent Job?
Explain system rowset functions?
How to select true false based on column value in sql server?
How to set database to be single_user in ms sql server?
Explain encryption of entire databases without the need for application changes in sql server 2008?
How can you hide the sql server instances?
What are the disadvantages of using querystrings to send data from one page to another?
How to link tables in sql server?
What is data modeling and Reterminal integrity?
What is the stuff?
How to delete an existing row with delete statements in ms sql server?
can an order by clause be used in a creation of a view?
What is resource governor?
What is an index. What are the types?