<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Check for the Existence of a Temp Table</title>
	<atom:link href="http://facility9.com/2009/04/14/check-for-the-existence-of-a-temp-table/feed" rel="self" type="application/rss+xml" />
	<link>http://facility9.com/2009/04/14/check-for-the-existence-of-a-temp-table</link>
	<description>Jeremiah Peschka&#039;s ruminations on sql, ruby, c#, and other things</description>
	<lastBuildDate>Wed, 28 Jul 2010 14:05:12 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jeremiah Peschka</title>
		<link>http://facility9.com/2009/04/14/check-for-the-existence-of-a-temp-table#comment-469</link>
		<dc:creator>Jeremiah Peschka</dc:creator>
		<pubDate>Tue, 14 Apr 2009 14:12:39 +0000</pubDate>
		<guid isPermaLink="false">http://facility9.com/?p=493#comment-469</guid>
		<description>D. Lambert - 

Very true. Table variables definitely have their place, especially when dealing with smaller amounts of data. (Nice post on table variables, by the way.)

However, the table variables will still be around (just like temp tables) if I&#039;m messing around in SSMS before I run a CREATE PROCEDURE and commit my changes to the database. I can&#039;t tell you the number of times I&#039;ve forgotten to remove a temporary table. Then I look like an idiot in front the developers and they get one more reason to mock me apart from my TSQL license plate.

Plus, when you&#039;re working with dynamic SQL, temp tables are reused by the code you execute via sp_executesql, whereas table variables are not (they&#039;re out of scope), so you&#039;ll have to make multiple calls to retrieve the same data. This way I can build dynamic SQl that uses the contents of temp tables for decision making as well as for joins in the final query.

Also, table variables are always assumed to have 1 row by the algebrizer. For my needs, the limitations of table variables render them largely useless since I deal largely with dynamic SQL working to aggregate large result sets (see &lt;a href=&quot;http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html&quot; rel=&quot;nofollow&quot;&gt;Should I use a #temp table or a @table variable?&lt;/a&gt; for more). I&#039;m including the link for others following along, not because I think you don&#039;t know any better.</description>
		<content:encoded><![CDATA[<p>D. Lambert &#8211; </p>
<p>Very true. Table variables definitely have their place, especially when dealing with smaller amounts of data. (Nice post on table variables, by the way.)</p>
<p>However, the table variables will still be around (just like temp tables) if I&#8217;m messing around in SSMS before I run a CREATE PROCEDURE and commit my changes to the database. I can&#8217;t tell you the number of times I&#8217;ve forgotten to remove a temporary table. Then I look like an idiot in front the developers and they get one more reason to mock me apart from my TSQL license plate.</p>
<p>Plus, when you&#8217;re working with dynamic SQL, temp tables are reused by the code you execute via sp_executesql, whereas table variables are not (they&#8217;re out of scope), so you&#8217;ll have to make multiple calls to retrieve the same data. This way I can build dynamic SQl that uses the contents of temp tables for decision making as well as for joins in the final query.</p>
<p>Also, table variables are always assumed to have 1 row by the algebrizer. For my needs, the limitations of table variables render them largely useless since I deal largely with dynamic SQL working to aggregate large result sets (see <a href="http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html" rel="nofollow">Should I use a #temp table or a @table variable?</a> for more). I&#8217;m including the link for others following along, not because I think you don&#8217;t know any better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: D. Lambert</title>
		<link>http://facility9.com/2009/04/14/check-for-the-existence-of-a-temp-table#comment-468</link>
		<dc:creator>D. Lambert</dc:creator>
		<pubDate>Tue, 14 Apr 2009 13:36:24 +0000</pubDate>
		<guid isPermaLink="false">http://facility9.com/?p=493#comment-468</guid>
		<description>Don&#039;t forget about table variables for smaller applications -- they clean up after themselves very nicely.</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget about table variables for smaller applications &#8212; they clean up after themselves very nicely.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
