<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Table Variable &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/table-variable/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Wed, 23 May 2018 19:10:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Server 2014: Examples of Table Variable with Indexes</title>
		<link>https://www.dbrnd.com/2018/06/sql-server-2014-examples-of-table-variable-with-indexes/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 11 Jun 2018 16:16:29 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[indexes]]></category>
		<category><![CDATA[SQL Programming]]></category>
		<category><![CDATA[sql queries]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[SQL Sever 2014]]></category>
		<category><![CDATA[sqlcode]]></category>
		<category><![CDATA[Table Variable]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7653</guid>

					<description><![CDATA[I didn&#8217;t explore few features of SQL Server 2014. Recently, I got to know that in SQL Server 2014 we can create indexes on Table Variable. If you look into the differences between Temp Table and Table Variable, always you can find one difference like we can&#8217;t create an index on Table Variable and we [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F06%2Fsql-server-2014-examples-of-table-variable-with-indexes%2F&amp;linkname=SQL%20Server%202014%3A%20Examples%20of%20Table%20Variable%20with%20Indexes" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F06%2Fsql-server-2014-examples-of-table-variable-with-indexes%2F&amp;linkname=SQL%20Server%202014%3A%20Examples%20of%20Table%20Variable%20with%20Indexes" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F06%2Fsql-server-2014-examples-of-table-variable-with-indexes%2F&amp;linkname=SQL%20Server%202014%3A%20Examples%20of%20Table%20Variable%20with%20Indexes" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F06%2Fsql-server-2014-examples-of-table-variable-with-indexes%2F&amp;linkname=SQL%20Server%202014%3A%20Examples%20of%20Table%20Variable%20with%20Indexes" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F06%2Fsql-server-2014-examples-of-table-variable-with-indexes%2F&amp;linkname=SQL%20Server%202014%3A%20Examples%20of%20Table%20Variable%20with%20Indexes" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F06%2Fsql-server-2014-examples-of-table-variable-with-indexes%2F&amp;linkname=SQL%20Server%202014%3A%20Examples%20of%20Table%20Variable%20with%20Indexes" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F06%2Fsql-server-2014-examples-of-table-variable-with-indexes%2F&#038;title=SQL%20Server%202014%3A%20Examples%20of%20Table%20Variable%20with%20Indexes" data-a2a-url="https://www.dbrnd.com/2018/06/sql-server-2014-examples-of-table-variable-with-indexes/" data-a2a-title="SQL Server 2014: Examples of Table Variable with Indexes"></a></p><p>I didn&#8217;t explore few features of SQL Server 2014. Recently, I got to know that in SQL Server 2014 we can create indexes on Table Variable. </p>
<p>If you look into the differences between Temp Table and Table Variable, always you can find one difference like we can&#8217;t create an index on Table Variable and we can create an index on the Temp Table. </p>
<blockquote class="wp-embedded-content" data-secret="oa9njLGXKU"><p><a href="https://www.dbrnd.com/2016/02/sql-server-difference-between-temporary-table-and-table-variable/">SQL Server: Difference between Temporary Table and Table Variable</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/02/sql-server-difference-between-temporary-table-and-table-variable/embed/#?secret=oa9njLGXKU" data-secret="oa9njLGXKU" width="600" height="338" title="&#8220;SQL Server: Difference between Temporary Table and Table Variable&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>In this post, I am sharing few examples of Table variable with Indexes.<br />
Please check the below samples:</p>
<p><strong>Define Table variable with Primary key and Unique key:</strong></p>
<pre class="crayon-plain-tag">DECLARE @dbrnd TABLE
(
	ID INT PRIMARY KEY
	,Name NVARCHAR(10) UNIQUE
)</pre> </p>
<p><strong>Define Table variable with Non-Clustered index:</strong></p>
<pre class="crayon-plain-tag">DECLARE @dbrnd TABLE
(
	ID INT PRIMARY KEY
	,Name NVARCHAR(20)
	,INDEX idx_dbrnd_Name NONCLUSTERED (Name)
)</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-5)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 16 Jun 2016 18:12:49 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[cardinality]]></category>
		<category><![CDATA[cte]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database joins]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Table Variable]]></category>
		<category><![CDATA[Temp Table]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3045</guid>

					<description><![CDATA[What is an Inner join? The join that displays only the rows that have a match in both the joined tables is known as inner join. What is an Equi join? Equi join is a special type of join in which we use only equality operator. Hence, when you make a query for join using [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-5%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-5%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-5%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-5%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-5%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-5%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-5%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-database-join-temporary-table-table-variable-cardinality-day-5/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-5)"></a></p><p><strong>What is an Inner join?</strong></p>
<blockquote><p>The join that displays only the rows that have a match in both the joined tables is known as inner join.</p></blockquote>
<p><strong>What is an Equi join?</strong></p>
<blockquote><p>Equi join is a special type of join in which we use only equality operator. Hence, when you make a query for join using equality operator, then that join query comes under Equi join.</p>
<p>Equi join has only (=) operator in join condition.</p>
<p>Equi join can be inner join, left outer join, right outer join.</p></blockquote>
<p><strong>What is a Left Outer join?</strong></p>
<blockquote><p>Left join displays all the rows from the first table and matched rows from second table like that.</p></blockquote>
<p><strong>What is a Right outer join?</strong></p>
<blockquote><p>Right outer join displays all the rows of second table and matched rows from first table.</p></blockquote>
<p><strong>What is a Full outer join?</strong></p>
<blockquote><p>Full outer join returns all the rows from both tables whether it has been matched or not.</p></blockquote>
<p><strong>What is a Cross Join?</strong></p>
<blockquote><p>A cross join that produces Cartesian product of the tables that are involved in the join. The size of a Cartesian product is the number of the rows in the first table multiplied by the number of rows in the second table.</p></blockquote>
<p><strong>What is a Self join?</strong></p>
<blockquote><p>Joining the table itself called self join. Self join is used to retrieve the records having some relation or similarity with other records in the same table. Here, we need to use aliases for the same table to set a self join between single table and retrieve records satisfying the condition in where clause</p></blockquote>
<p><strong>What is the difference between cross join and Full outer join?</strong></p>
<p><strong>Cross Join:</strong></p>
<ul>
<li>It produces the Cartesian product.</li>
<li>Results in Cartesian product of two tables.</li>
<li>Results in pairs of rows.</li>
<li>No join conditions are specified.</li>
</ul>
<p><strong>Full Outer Join:</strong></p>
<ul>
<li>It includes all the rows from both the tables.</li>
<li>Assigns NULL for unmatched fields.</li>
<li>Results in every row from both of the tables , at least once.</li>
<li>A combination of both left and right outer joins.</li>
</ul>
<p><strong>What is the difference between Temp table and Common table Expression (CTE)?</strong></p>
<blockquote class="wp-embedded-content" data-secret="7sE1TwDePR"><p><a href="https://www.dbrnd.com/2016/02/sql-server-difference-between-temp-table-and-common-table-expression-cte/">SQL Server: Difference between Temp Table and Common Table Expression (CTE)</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/02/sql-server-difference-between-temp-table-and-common-table-expression-cte/embed/#?secret=7sE1TwDePR" data-secret="7sE1TwDePR" width="600" height="338" title="&#8220;SQL Server: Difference between Temp Table and Common Table Expression (CTE)&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the difference between Temp table and Table Variable?</strong></p>
<blockquote class="wp-embedded-content" data-secret="5yNwchT1WL"><p><a href="https://www.dbrnd.com/2016/02/sql-server-difference-between-temporary-table-and-table-variable/">SQL Server: Difference between Temporary Table and Table Variable</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/02/sql-server-difference-between-temporary-table-and-table-variable/embed/#?secret=5yNwchT1WL" data-secret="5yNwchT1WL" width="600" height="338" title="&#8220;SQL Server: Difference between Temporary Table and Table Variable&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the difference between Local and Global Temp Table?</strong></p>
<p>There are two types of temporary tables: local and global. Local temporary tables are visible only to their creators during the same connection to an instance of SQL Server as when the tables were first created or referenced. Local temporary tables are deleted after the user disconnects from the instance of SQL Server. Global temporary tables are visible to any user and any connection after they are created, and are deleted when all users that are referencing the table disconnect from the instance of SQL Server.</p>
<p><strong>How to execute Large SQL Script File by using SQLCmd?</strong></p>
<blockquote><p>sqlcmd -S [servername] -d [databasename] -i [scriptfilename]</blockquote>
<p><strong>What is ASCII method?</strong></p>
<blockquote><p>ASCII will return the ascii value of the character expression.</p></blockquote>
<p><strong>Would do you please write syntax of table variable?</strong></p>
<blockquote><p>DECLARE @TableVariabl Table (ID INT, Name VARCHAR(150))</p></blockquote>
<p><strong>How do we unlock particular user in SQL Server?</strong></p>
<blockquote><p>First login with system admin user and execute below ALTER command.</p>
<p>ALTER LOGIN login_name WITH password=&#8217;password&#8217; unlock;</p></blockquote>
<p><strong>What is the performance difference between EXISTS and IN?</strong></p>
<blockquote><p>EXISTS is efficient as if any row returned and it stops the further search.</p>
<p>IN is looking for a specific match which takes longer.</p>
<p>However, they may not always replace each other and we should use as per our system requirements.</p></blockquote>
<p><strong>Is SQL Case sensitive?</strong></p>
<blockquote><p>No: SQL is not case sensitive.</p></blockquote>
<p><strong>What are the different types of cardinality in SQL?</strong></p>
<blockquote><p><strong>High-cardinality:</strong> refers to columns with values that are very uncommon or unique. High-cardinality column values are typically identification numbers, email addresses, or user names. An example of a data table column with high-cardinality would be a USERS table with a column named USER_ID. This column would contain unique values of 1-n. Each time a new user is created in the USERS table, a new number would be created in the USER_ID column to identify them uniquely. Since the values held in the USER_ID column are unique, this column&#8217;s cardinality type would be referred to as high-cardinality.</p>
<p><strong>Normal-cardinality:</strong> refers to columns with values that are somewhat uncommon. Normal-cardinality column values are typically names, street addresses, or vehicle types. An example of a data table column with normal-cardinality would be a CUSTOMER table with a column named LAST_NAME, containing the last names of customers. While some people have common last names, such as Smith, others have uncommon last names. Therefore, an examination of all of the values held in the LAST_NAME column would show &#8220;clumps&#8221; of names in some places (e.g. a lot of Smith&#8217;s) surrounded on both sides by a long series of unique values. Since there is a variety of possible values held in this column, its cardinality type would be referred to as normal-cardinality.</p>
<p><strong>Low-cardinality:</strong> refers to columns with few unique values. Low-cardinality column values are typically status flags, Boolean values, or major classifications such as gender. An example of a data table column with low-cardinality would be a CUSTOMER table with a column named NEW_CUSTOMER. This column would contain only two distinct values: Y or N, denoting whether the customer was new or not. Since there are only two possible values held in this column, its cardinality type would be referred to as low-cardinality.</p></blockquote>
<p><strong>How to find any Text, Column, Comment, Object Name in SQL Server Objects?</strong></p>
<blockquote class="wp-embedded-content" data-secret="LHHgugG5ak"><p><a href="https://www.dbrnd.com/2015/06/how-to-find-any-text-column-comment-object-name-in-sql-server-objects/">How to find any Text, Column, Comment, Object Name in SQL Server Objects</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/06/how-to-find-any-text-column-comment-object-name-in-sql-server-objects/embed/#?secret=LHHgugG5ak" data-secret="LHHgugG5ak" width="600" height="338" title="&#8220;How to find any Text, Column, Comment, Object Name in SQL Server Objects&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>How to Find Missing Number and ID in the SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="nb1IILJnvE"><p><a href="https://www.dbrnd.com/2015/06/query-to-find-missing-number-id-sql-server/">Query to Find Missing Number and ID in SQL Server</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/06/query-to-find-missing-number-id-sql-server/embed/#?secret=nb1IILJnvE" data-secret="nb1IILJnvE" width="600" height="338" title="&#8220;Query to Find Missing Number and ID in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Difference between Temporary Table and Table Variable</title>
		<link>https://www.dbrnd.com/2016/02/sql-server-difference-between-temporary-table-and-table-variable/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 12 Feb 2016 18:54:45 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[Table Variable]]></category>
		<category><![CDATA[Temp Table]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1597</guid>

					<description><![CDATA[Sharing one of the timeworn topics and we can also find an N number of good articles on this. I also like this topic very much so I would like to write a small note on this. First, Very important point: Temp table is stored in TempDB and Table variable is stored in Memory. The [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fsql-server-difference-between-temporary-table-and-table-variable%2F&amp;linkname=SQL%20Server%3A%20Difference%20between%20Temporary%20Table%20and%20Table%20Variable" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fsql-server-difference-between-temporary-table-and-table-variable%2F&amp;linkname=SQL%20Server%3A%20Difference%20between%20Temporary%20Table%20and%20Table%20Variable" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fsql-server-difference-between-temporary-table-and-table-variable%2F&amp;linkname=SQL%20Server%3A%20Difference%20between%20Temporary%20Table%20and%20Table%20Variable" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fsql-server-difference-between-temporary-table-and-table-variable%2F&amp;linkname=SQL%20Server%3A%20Difference%20between%20Temporary%20Table%20and%20Table%20Variable" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fsql-server-difference-between-temporary-table-and-table-variable%2F&amp;linkname=SQL%20Server%3A%20Difference%20between%20Temporary%20Table%20and%20Table%20Variable" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fsql-server-difference-between-temporary-table-and-table-variable%2F&amp;linkname=SQL%20Server%3A%20Difference%20between%20Temporary%20Table%20and%20Table%20Variable" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F02%2Fsql-server-difference-between-temporary-table-and-table-variable%2F&#038;title=SQL%20Server%3A%20Difference%20between%20Temporary%20Table%20and%20Table%20Variable" data-a2a-url="https://www.dbrnd.com/2016/02/sql-server-difference-between-temporary-table-and-table-variable/" data-a2a-title="SQL Server: Difference between Temporary Table and Table Variable"></a></p><p>Sharing one of the timeworn topics and we can also find an N number of good articles on this. </p>
<p>I also like this topic very much so I would like to write a small note on this.</p>
<p><strong>First, Very important point:</strong></p>
<blockquote><p>Temp table is stored in TempDB and Table variable is stored in Memory.<br />
<strong>The above statement is 100% wrong.  </strong><br />
Table variable is also stored definition into TempDB and if the data volume is increased, sometimes it also stores data into TempDB. </p></blockquote>
<p><strong><code>For that reason, SQL Server 2014 introduced Hekaton storage engine for Memory optimized Table.<br />
<a href="https://www.dbrnd.com/2016/01/sql-server-2014-what-is-hekaton/" target="_blank">"SQL Server 2014: What is Hekaton?"</a><br />
<a href="https://www.dbrnd.com/2016/01/sql-server-2014-create-memory-optimized-file-group-and-table/" target="_blank">"SQL Server 2014: Create Memory Optimized File Group and Table"</a></code></strong></p>
<blockquote><p>If we require creating a unique index on data, we should use Temporary Table. We cannot apply Index on Table Variable. </p></blockquote>
<blockquote><p>If we are dealing with large number records for inserting and deleting, we should use a temporary table. If we have a small quantity of data, we should use Table Variable. </p></blockquote>
<blockquote><p>If the amount of data is frequently changing, query planner requires updated statistics to recompile object so for that we should use Temporary Table.<br />
If the amount of data is not frequently changing, we should use Table Variable for better performance.</p></blockquote>
<blockquote><p>When we require rollback because of an outer user transaction, we should use Table Variable because it automatically discard all the data from the session.</p></blockquote>
<blockquote><p>If we would like to avoid locking issue, we should go with Table Variable because Temp Table is fully dependent on TempDB so sometimes it holds the transactions. </p></blockquote>
<blockquote><p>We can define explicit transaction on Temp Table where with the Table Variable we cannot define explicit transaction.</p></blockquote>
<blockquote><p>The maintenance and creation of metadata for Table Variable requires less time than Temp Table.</p></blockquote>
<blockquote><p>The scope of Table Variable is up to batch or stored procedure after completion of execution it drops automatically.<br />
The scope of Temp Table is up to sessions, and once the session ends, it drops automatically, or we can also drop explicitly. </p></blockquote>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
