How to avoid cursors?

Answers were Sorted based on User's Feedback



How to avoid cursors?..

Answer / mahima

to avoid cursor use CASE and SET .
to give increment to the employee depending upon the salary

update empsal
set
case when sal between 2000 AND 3000 then sal+1000
when sal between 3000 AND 4000 then sal+2000
end

Is This Answer Correct ?    6 Yes 3 No

How to avoid cursors?..

Answer / veeresh kethari

1.By using case.. set,we can avoid the cursors

2.By using temporary tables/table variables/CTE
with while loop we can avoid cursor in the transaction.

Is This Answer Correct ?    3 Yes 1 No

How to avoid cursors?..

Answer / sunny

update salary set sal=(
case
when sal between 100 and 300 then sal + 1000
when sal between 300 and 500 then sal + 2000
when sal between 500 and 700 then sal + 3000
end)

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More SQL Server Interview Questions

What are wait types?

0 Answers  


What is bcp? When does it used?

0 Answers  


What is an indice?

0 Answers  


What is the use of toad or sqldbx.?

0 Answers   MCN Solutions,


What is a group function explain with an example?

0 Answers  






Write the syntax for stuff function in an sql server?

0 Answers  


Define Foreign Key?

3 Answers   ADP, College School Exams Tests,


What is the best way to move n number of DTS package from one SQLServer to another SQLServer?

1 Answers   RBS,


Which sql server table is used to hold the stored procedure scripts?

0 Answers  


Let us say master db itself has no backup. Now you have to rebuild the db so what kind of action do you take?

1 Answers  


What is unique key constraint?

0 Answers  


What is used to replicate sessions between instances in coldfusion clusters?

0 Answers   HCL,


Categories