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 indexed view?
Explain the collation?
how many triggers you can have on a table? : Sql server database administration
How will you optimize a stored procedure optimization?
Is it true, that there is no difference between a rule and a check constraint?
What is a DBMS, query, SQL?
What is primary key index?
Define self join in sql server joins?
Is sql server 2016 free?
How to disable triggers using "disable trigger"?
What is the difference between the application object and session object?
What is use of attribute hierarchy ordered ? : sql server analysis services, ssas
What is the default port for SQL Server over a firewall?
List layers of abstraction microsoft architectured to provide relational db through cloud platform ?
What do you understand by user-defined function in the sql server and explain the steps to create and execute a user-defined function in the sql server?