Click here to Skip to main content
15,888,088 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,


Please tell which is best to replace cursor

1 temporary table
2 common table expression
3 View
Posted

First of all your question is wrong as like as Sandeep said.

Alternatives to using a cursor:
- Use WHILE LOOPS
- Use temp tables
- Use derived tables
- Use correlated sub-queries
- Use the CASE statement
- Perform multiple queries


But Here I gave you the links for
"Alternatives for Cursors" & "Comparisons between those things" & "etc., things"

Comparing cursor vs. WHILE loop performance in SQL Server 2008[^]

Cursor vs While loop. What are advantage/disadvantages of cursors[^]

Cursor vs Temp Table vs Table Variable performance[^]

Performance Tuning SQL Server Cursors[^]

USING SQL SERVER 2000 TABLE VARIABLES
TO ELIMINATE THE NEED FOR CURSORS
[^]

SQL SERVER – Comparison : Similarity and Difference #TempTable vs @TempVariable[^]
 
Share this answer
 
Comments
Dylan Morley 3-Mar-11 9:18am    
good links
You need to read on dude!

If you would have know what are 1, 2 & 3.. it would be hardly take 2 seconds to reply back. Further, you should have atleast Googled on what 1, 2 & 3 are.

2 & 3 are no where what a cursor does. Temporary tables work can be replaced by cursors at time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900