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 the difference between implicit and explicit transaction?
Explain error and transaction handling in sql server?
What is the difference between indexing and hashing?
Explain following error properties?
What is the significance of master, tempdb and model databases?
Why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it?
Explain some stored procedure creating best practices or guidelines?
How does stuff differ from the replace function?
What the different topologies in which replication can be configured?
How can you know if the row fetched from cursor is still valid in underlying table?
what is a join and explain different types of joins? : Sql server database administration
what is unique and xaml nonclustered index
What is named query? : sql server analysis services, ssas
What are the limitations in ssrs on sql server express edition?
Explain nested trigger in sql?