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

Why use update_statistics command in sql server?

0 Answers  


How to provide default values to function parameters?

0 Answers  


What is 1nf 2nf?

0 Answers  


what is cluster and nin-cluster index?

4 Answers  


When should you use an instead of trigger?

0 Answers  






Tell me when is the update_statistics command used?

0 Answers  


What is xml datatype?

0 Answers  


Is null vs coalesce?

0 Answers  


How do I find the default sql server instance?

0 Answers  


Explain what is sql server english query?

0 Answers  


Explain what is it unwise to create wide clustered index keys?

0 Answers  


what are the critical issues you have resloved in your company

0 Answers   Wipro,


Categories