How can we write a a query without using temporary tables in detail explanation in SQL
I need the deep explanation for the queries that are not using the temporary tables in SQL Server 2008 and without using the cursors.
开发者_Python百科Thanks, Vara Prasad.M
You want to use a variable table with an identity and iterate through it (also known as RBAR [Row By Agonizing Row]) over using a cursor for several reasons:
- Cursors lock the row - you can do more with a cursor such as moving backwards and updating but you're accessing your table
- Using a variable table keeps the data in memory which is faster than using a physical table
- Personally, I've been bitten too many times by forgetting to deallocate my cursor
精彩评论