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

I am using SQL Server 2005, I have some select and update statements in my query with WHERE clause I want to prevent these queries from SQL injection attacks. What are the steps and precautions to be taken for SQL Injection attacks? Does anybody have suggestions? Thanks in advance,

2 Answers  


What is tablesample?

0 Answers  


What the different types of Replication and why are they used?

0 Answers  


What is a functions and types in sql server?

0 Answers  


Can you explain how long are locks retained within the repeatable_read and serializable isolation levels, during a read operation with row-level locking?

0 Answers  






Do you know what are different types of replication in sql server?

0 Answers  


How is foreign key related to primary key?

0 Answers  


What is statement level trigger?

0 Answers  


What functions can a view be used to performed?

0 Answers  


How to use transact-sql statements to access the database engine?

0 Answers  


Do you know exporting and importing utility?

0 Answers  


How to verify a login name with sqlcmd tool?

0 Answers  


Categories