how to create a scrollable cursor with the scroll option? : Sql server database administration



how to create a scrollable cursor with the scroll option? : Sql server database administration..

Answer / Pradip Kumar Srivastava

"DECLARE @cursor CURSOR FOR SELECT * FROM table_name; OPEN @cursor; DECLARE @row CURSOR_STATUS; SET @row = 0; WHILE (@row <> -1) BEGIN FETCH NEXT FROM @cursor INTO @var1, @var2, ..., @varN; SELECT @row = @@FETCH_STATUS; IF (@row > 0) CONTINUE; END; CLOSE @cursor; DEALLOCATE @cursor": This code creates a scrollable cursor that allows you to move backward and forward through the result set. The addition of the "scroll" option in the FETCH NEXT statement enables this functionality.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What is Self Join?

4 Answers  


What is an active database?

1 Answers   HCL,


How to create user defined functions with parameters?

1 Answers  


What are the restraints imposed on the table design by a merge replication?

1 Answers  


Due to some maintenance being done, the sql server on a failover cluster needs to be brought down. How do you bring the sql server down?

1 Answers  


What is use of @@ spid in sql server?

1 Answers  


Explain why variables called the most powerful component of ssis?

1 Answers  


How do I list the available tables in a database I'm querying?

4 Answers  


which backup strategy you are following at ur company

1 Answers  


When do u use clustered index and non-clustered index?

3 Answers   IBM,


What are the differences between union, intersect, and minus operators?

1 Answers  


What are the types of constraints?

1 Answers  


Categories