<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Comparison : Similarity and Difference  #TempTable vs @TempVariable</title>
	<atom:link href="http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Mon, 13 Feb 2012 15:11:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Biju Sasidharan</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-230572</link>
		<dc:creator><![CDATA[Biju Sasidharan]]></dc:creator>
		<pubDate>Tue, 03 Jan 2012 10:20:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-230572</guid>
		<description><![CDATA[And the following will be working...........!!

declare @var_ varchar(1000)
declare @var_table table(To_day datetime)
set @var_=&#039;select convert(varchar,getdate(),101) as ToDay &#039;
insert into @var_table 
execute (@var_)
select * from @var_table]]></description>
		<content:encoded><![CDATA[<p>And the following will be working&#8230;&#8230;&#8230;..!!</p>
<p>declare @var_ varchar(1000)<br />
declare @var_table table(To_day datetime)<br />
set @var_=&#8217;select convert(varchar,getdate(),101) as ToDay &#8216;<br />
insert into @var_table<br />
execute (@var_)<br />
select * from @var_table</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Biju Sasidharan</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-217364</link>
		<dc:creator><![CDATA[Biju Sasidharan]]></dc:creator>
		<pubDate>Wed, 14 Dec 2011 06:55:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-217364</guid>
		<description><![CDATA[Hi Readers, 
Please consider the following situation ,
Here part (1) will render the result but not part (2) and (4)
Can any one suggest an answer, why the temp table and table variable canot be used in string level execution.
In part (2) it will execute, but while fetching the value (select * from #tmp_date) it will generate error, 
but part(3) will render the result(select * from ##tmp_date).

(1) Table
select convert(varchar,getdate(),101) as ToDay into dat_date
select * from dat_date
drop table dat_date

(2)Temporary table
declare @var varchar(1000)
set @var=&#039;select convert(varchar,getdate(),101) as ToDay into #tmp_date&#039;
execute (@var)
select * from #tmp_date
drop table #tmp_date

(3)Temporary table
declare @var varchar(1000)
set @var=&#039;select convert(varchar,getdate(),101) as ToDay into ##tmp_date&#039;
execute (@var)
select * from ##tmp_date
drop table ##tmp_date

(4)Table variable
declare @var_ varchar(1000)
declare @var_table table(To_day datetime)
set @var_=&#039;insert into @var_table select convert(varchar,getdate(),101) as ToDay &#039;
execute (@var_)
select * from @var_table
drop table @var_table

Any guesses?? please post...!]]></description>
		<content:encoded><![CDATA[<p>Hi Readers,<br />
Please consider the following situation ,<br />
Here part (1) will render the result but not part (2) and (4)<br />
Can any one suggest an answer, why the temp table and table variable canot be used in string level execution.<br />
In part (2) it will execute, but while fetching the value (select * from #tmp_date) it will generate error,<br />
but part(3) will render the result(select * from ##tmp_date).</p>
<p>(1) Table<br />
select convert(varchar,getdate(),101) as ToDay into dat_date<br />
select * from dat_date<br />
drop table dat_date</p>
<p>(2)Temporary table<br />
declare @var varchar(1000)<br />
set @var=&#8217;select convert(varchar,getdate(),101) as ToDay into #tmp_date&#8217;<br />
execute (@var)<br />
select * from #tmp_date<br />
drop table #tmp_date</p>
<p>(3)Temporary table<br />
declare @var varchar(1000)<br />
set @var=&#8217;select convert(varchar,getdate(),101) as ToDay into ##tmp_date&#8217;<br />
execute (@var)<br />
select * from ##tmp_date<br />
drop table ##tmp_date</p>
<p>(4)Table variable<br />
declare @var_ varchar(1000)<br />
declare @var_table table(To_day datetime)<br />
set @var_=&#8217;insert into @var_table select convert(varchar,getdate(),101) as ToDay &#8216;<br />
execute (@var_)<br />
select * from @var_table<br />
drop table @var_table</p>
<p>Any guesses?? please post&#8230;!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jc</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-54984</link>
		<dc:creator><![CDATA[jc]]></dc:creator>
		<pubDate>Tue, 18 Aug 2009 17:51:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-54984</guid>
		<description><![CDATA[Dave,

We have a procedure that is ran evry 2 minutes in a windows service.  The procedure uses a table variable.  It appears tha after a couple hours of execution the server that this service is running on starts to take a performance hit.  We have also seen a tremendous increase in timeouts since the implementation of this stored procedure.  Is ti possible that the table variable is not being released from memeory?]]></description>
		<content:encoded><![CDATA[<p>Dave,</p>
<p>We have a procedure that is ran evry 2 minutes in a windows service.  The procedure uses a table variable.  It appears tha after a couple hours of execution the server that this service is running on starts to take a performance hit.  We have also seen a tremendous increase in timeouts since the implementation of this stored procedure.  Is ti possible that the table variable is not being released from memeory?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-47226</link>
		<dc:creator><![CDATA[SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:09:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-47226</guid>
		<description><![CDATA[[...] SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; Comparison : Similarity and Difference #TempTable vs @TempVariable [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable - Part 2 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-38526</link>
		<dc:creator><![CDATA[SQL SERVER - SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable - Part 2 Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Tue, 20 May 2008 11:11:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-38526</guid>
		<description><![CDATA[[...] I have previously wrote about this indepth here : SQL SERVER - Comparison : Similarity and Difference #TempTable vs @TempVariable [...]]]></description>
		<content:encoded><![CDATA[<p>[...] I have previously wrote about this indepth here : SQL SERVER &#8211; Comparison : Similarity and Difference #TempTable vs @TempVariable [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rishi22</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-32787</link>
		<dc:creator><![CDATA[Rishi22]]></dc:creator>
		<pubDate>Tue, 15 Jan 2008 02:42:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-32787</guid>
		<description><![CDATA[Hi,

I have a table with columns
distributor_id ,
brand_id,
year,
month,
total_sales


distributor_id ,
brand_id,
year,
month are my primary keys.

I have records for last 3 years od data.

I have distinct records till last year,
Some are till last month (Current month - 1)
some are till feb 2007.......
some are till jan 2007..


Now i want to insert records to all distinct
distributor_id ,
brand_id,
year,
month
Zero  for sales 

where i have to take max month + 1 and hardcode as zero till current month + 10 months.

i appreciate if you get me a insert script without cursors.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have a table with columns<br />
distributor_id ,<br />
brand_id,<br />
year,<br />
month,<br />
total_sales</p>
<p>distributor_id ,<br />
brand_id,<br />
year,<br />
month are my primary keys.</p>
<p>I have records for last 3 years od data.</p>
<p>I have distinct records till last year,<br />
Some are till last month (Current month &#8211; 1)<br />
some are till feb 2007&#8230;&#8230;.<br />
some are till jan 2007..</p>
<p>Now i want to insert records to all distinct<br />
distributor_id ,<br />
brand_id,<br />
year,<br />
month<br />
Zero  for sales </p>
<p>where i have to take max month + 1 and hardcode as zero till current month + 10 months.</p>
<p>i appreciate if you get me a insert script without cursors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinay</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-9965</link>
		<dc:creator><![CDATA[Vinay]]></dc:creator>
		<pubDate>Tue, 28 Aug 2007 13:18:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-9965</guid>
		<description><![CDATA[Very good site listing 
I agree with you on all but one comment about using temp tables.
Use temp tables if:
Results set is very large (greater than 100K rows)


I think it is efficient to use staging physical tables if result set is very large.  because of sp recompilation, locks on  tempdb and better use of parallelism]]></description>
		<content:encoded><![CDATA[<p>Very good site listing<br />
I agree with you on all but one comment about using temp tables.<br />
Use temp tables if:<br />
Results set is very large (greater than 100K rows)</p>
<p>I think it is efficient to use staging physical tables if result set is very large.  because of sp recompilation, locks on  tempdb and better use of parallelism</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-4277</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Tue, 03 Jul 2007 17:29:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-4277</guid>
		<description><![CDATA[Shikanth,

If you read what you have found and it is clearly stated what I have said and it confirms it. They still perform I/O on &lt;b&gt;tempdb&lt;/b&gt;.

&quot;A table variable is created in memory, and so performs slightly better than #temp tables (also because there is even less locking and logging in a table variable). A table variable might still perform I/O to tempdb (which is where the performance issues of #temp tables make themselves apparent), though the documentation is not very explicit about this. &quot;]]></description>
		<content:encoded><![CDATA[<p>Shikanth,</p>
<p>If you read what you have found and it is clearly stated what I have said and it confirms it. They still perform I/O on <b>tempdb</b>.</p>
<p>&#8220;A table variable is created in memory, and so performs slightly better than #temp tables (also because there is even less locking and logging in a table variable). A table variable might still perform I/O to tempdb (which is where the performance issues of #temp tables make themselves apparent), though the documentation is not very explicit about this. &#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srikanth</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-4275</link>
		<dc:creator><![CDATA[srikanth]]></dc:creator>
		<pubDate>Tue, 03 Jul 2007 16:58:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-4275</guid>
		<description><![CDATA[I found the link.
http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html]]></description>
		<content:encoded><![CDATA[<p>I found the link.<br />
<a href="http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html" rel="nofollow">http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srikanth</title>
		<link>http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-4274</link>
		<dc:creator><![CDATA[srikanth]]></dc:creator>
		<pubDate>Tue, 03 Jul 2007 16:56:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/07/03/sql-server-comparison-similarity-and-difference-temptable-vs-tempvariable/#comment-4274</guid>
		<description><![CDATA[You have stated that both temp table and table variable instantiated in tempdb. But I remember reading that table variables are stored in memory. Could you please confirm.]]></description>
		<content:encoded><![CDATA[<p>You have stated that both temp table and table variable instantiated in tempdb. But I remember reading that table variables are stored in memory. Could you please confirm.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

