Write the Syntax for Cursors.

Answers were Sorted based on User's Feedback



Write the Syntax for Cursors...

Answer / 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

Write the Syntax for Cursors...

Answer / ranjith kumar

declare cursor_name cursor for
select * from table_name
open cursor_name
fetch next from cursor_name

Is This Answer Correct ?    6 Yes 2 No

Post New Answer

More SQL Server Interview Questions

What are the type of Indexes? which one is best, why?

6 Answers  


What is the difference between char and varchar2 datatype in sql?

0 Answers  


Following are some of the question related to below mentioned query? select e1.salary from employee3 e1 where 2= ( select count(distinct(e2.salary)) from employee3 e2 where e2.salary>=e1.salary ) 1) What the query returns? 2) How it works? - Detail explanation (what the sub query does, why it is (where 2=)....etc...Please?

5 Answers  


Explain left outer join and right outer join?

0 Answers  


What is the difference between Normalization and De-normalization?

0 Answers   TCS,






What are indexes? When do you need to create Indexes?

4 Answers   CarrizalSoft Technologies, HP,


Which data types generate inaccurate results if used with an = or <> comparison in a where clause of a sql statement?

0 Answers  


Define msdb database?

0 Answers  


Which is better in performance - CONSTRAINT or TRIGGER over a column which restricts say an input of particular value in a column of a table?

3 Answers   Accenture,


How does clustered and non clustered index work?

0 Answers  


What r sql reporting services and analysis services? how can we use it.

2 Answers   Microsoft,


How many ways to create table-valued functions?

0 Answers  


Categories