Alternatives for CURSOR in SQL Server
1)
Set-Based Commands
Set-based SQL commands are more efficient because you’re using SQL Server’s highly optimized engine to do your iteration. If you iterate through data yourself, you’re not using the SQL Server storage engine optimally.
In fact set-based commands like SELECT, UPDATE, and DELETE, when applied to tables directly and not in a cursor or WHILE loop, bring you closer logically to your data, precisely because you can ignore the order of the data
2)
CTE (Common Table Expressions)
Most of the times CTE's will be useful for recursive queries.....
Ex: To list of the parent-child-grand child chaining we can use CTE
3) Stored Procedure or User Defined Functions
we can say that "set-based commands / CTEs inside T-SQL " is also one of the alternative for CURSOR in SQL Server....
Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator