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
Does hive support indexing?
List some advantages and disadvantages of stored procedure?
How do I start sql server?
How to find Duplicate Records In table?
What are the restrictions that views have to follow? : SQL Server Architecture
what is the difference between count(*) and count(1) ?
What is scrollable cursor?
Can we use where and having clause together?
what protocol both networks use? : Sql server database administration
How to implement service broker?
What is a sql join?
How to name query output columns in ms sql server?
Why do we use sql limitations? Which constraints can we use while making a database in sql?
What is server-level principal?
Does a specific recovery model need to be used for a replicated database? : sql server replication