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

How can I check if a view exists in a sql server database?

0 Answers  


What are types of scd? : sql server analysis services, ssas

0 Answers  


Explain the use of containers in ssis and also their types?

0 Answers  


How many types of system privileges are there, Can we add or delete privileges?

2 Answers  


What are the advantages of user defined function?

0 Answers  






Explain about temporary stored procedure?

0 Answers  


You want to implement the one-to-one relationship while designing tables. How would you do it?

0 Answers  


How do you identify a foreign key?

0 Answers  


Which joins are sql server default?

0 Answers  


What is the difference between a Local temporary table and a Global temporary table? How is each one used?

2 Answers   HCL,


how many instance use in sql server 2005

4 Answers   EFI, HCL,


What is the latest version of microsoft sql server?

0 Answers  


Categories