Write the Syntax for Cursors.

Answer Posted / govardhana r

DECLARE @var1 varchar(20), @var2 varchar(20)

declare cursor_name cursor for
select val1,val2 from table_name

open cursor_name

fetch next from cursor_name
into @var1, @var2

while @@FETCH_STATUS = 0
begin
-----
-----
-----
fetch next from cursor_name
into @var1, @var2
end

close cursor_name
deallocate cursor_name

Is This Answer Correct ?    11 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When you should use a low fill factor?

527


Explain few of the new features of sql server 2008 management studio

526


What is sql server locking?

556


How to generate create view script on an existing view?

566


tell me what is blocking and how would you troubleshoot it? : Sql server database administration

489






What are the different types of locks in the database?

488


How many databases can we create in a single server?

187


How to find the second highest salary of an employee?

597


How to trouble shoot if unable to connect SQL Server

1482


Mention the differences between substr and charindex in sql server.

525


What is sub query and its properties?

549


How to generate create table script on an existing table in ms sql server?

645


What is the sql case statement used for? Explain with an example?

542


What is join query?

502


Explain about protocol layer present in SQL server?

611