Table Manners

Posted on September 03, 2004  |  

Posted in Development

No comments yet

Via Ryan Farley came a hysterical snip of T-SQL code which shows severe abuse of tempdb. A dB developer at my previous job introduced me to table variables a while ago as an eggcellent alternative to tempdb. I think table variables are badly overlooked which is why I decided to post this.

Instead of pretending to be a SQL guru (which I'm not) I figured I'd post links to some helpful online resources to get you started with table variables.

Temporary tables have been akin to tables used for page layout. Microsoft has a Knowledge Base article titled SQL Server 2000 - Table Variables which is a good intro. There's an article at SQL Server Magazine which lays it out for you what might befall your application should you push temp tables to the max. There's even a fix from Microsoft for those guilty of tempdb abuse.

For most needs a table variable is a much better alternative to a temporary table. Make sure to read SQL Server 2000 - Table Variables to get both sides of the story. Also, search SQL Server Books Online for table variables.