adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

List the ways in which dynamic sql can be executed?

1085


How to convert character strings into numeric values?

1189


What is in place upgrade in sql server?

1125


How efficient you are in oracle and SQL server?

1257


When should you use an instead of trigger?

1052


Can we shrink data file in sql server?

1127


How do I start sql server 2017?

1015


What are different types of constraints?

1000


what is the difference between openrowset and openquery?

1193


What is the difference between upgrade and migration in sql server?

1183


Can one drop a column from a table?

1088


What is sql or structured query language?

1226


How to rebuild the master database?

1165


What is an indexed view?

1021


How to enter binary string literals in ms sql server?

1243