Home > Sample chapters

Temporary Tables and Table Variables in Microsoft SQL Server 2008 T-SQL Programming

Conclusion

I hope this chapter helped you realize the significant differences between the various types of temporary objects supported by SQL Server. I had to dispel a few widespread myths, especially with regard to table variables. Remember that it’s typically advisable to use table variables for small tables and to compare table variables against temporary tables for the most critical queries. You realize that there’s a time and place for each type and that no one type is always preferable to the others. I gave you a summary table with the aspects and functionality of each type, which should help you make the right choices based on your needs. Also, remember to pay special attention to tempdb, which can become a bottleneck in your system, especially when working extensively with temporary tables.