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
How do I find the sql server instance name?
What are the rules to use the rowguidcol property to define a globally unique identifier column?
What are the different types of replication are there in sql server 2000?
What does it mean to invest in the index?
How many types of stored procedures are there in sql server?
What do you understand by hotfixes and patches in sql server?
How to create a user name in a database?
What is the difference between value type and reference type?
Explain something about security and SQL Azure?
Tell me what is fill factor?
Can you pass expressions to function parameters?
What is the purpose of grouping data in a report?
How we create SQL Server 2005 Reporting Services ? Give me Sample
What is an index in a database?
What guidelines should be followed to help minimize deadlocks?