<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6032850948458789302</id><updated>2025-07-21T05:39:05.199-07:00</updated><category term="SQL Server"/><category term="t-sql"/><category term="code"/><category term="Programming"/><category term="database"/><category term="DBA"/><category term="example"/><category term="function"/><category term="#databricks"/><category term="#pyspark"/><category term="sql query"/><category term="#dataframe"/><category term="CTE"/><category term="Performance"/><category term="stored procedure"/><category term="#python"/><category term="SSIS"/><category term="difference"/><category term="linkedlist"/><category term="schema"/><category term="string"/><category term="system tables"/><category term="#col"/><category term="#select"/><category term="BST"/><category term="PHP"/><category term="Performance Optimization"/><category term="SQL Server 2016"/><category term="UDF"/><category term="XML"/><category term="binary search tree"/><category term="conversion"/><category term="integer"/><category term="stack"/><category term="swap"/><category term="#alias"/><category term="#distinct"/><category term="#dropDuplicates"/><category term="#filter"/><category term="#json"/><category term="#lit"/><category term="#orderBy"/><category term="#selectExpr"/><category term="#sort"/><category term="#withColumn"/><category term="#withColumnRenamed"/><category term="AWK"/><category term="Given N numbers from 1 2 3  N-1 and one other number Find that one"/><category term="Max Server Memory"/><category term="Memory Behavior"/><category term="N integers"/><category term="Queue"/><category term="SARGABLE"/><category term="SQL Server 2012"/><category term="SQL Server 2014"/><category term="Table Partition"/><category term="Table Variables"/><category term="TempDB Configuration"/><category term="Temporal Tables"/><category term="Temporary Tables"/><category term="UNIX"/><category term="acyclic"/><category term="ancestor"/><category term="command"/><category term="common"/><category term="constraint"/><category term="cyclic"/><category term="delete"/><category term="delete duplicates"/><category term="error log"/><category term="even number of times"/><category term="execute sql task"/><category term="first non-repeated character"/><category term="given dates"/><category term="hashmap"/><category term="hashtable"/><category term="highest salary of employee"/><category term="in-place"/><category term="indexes"/><category term="indirect configuration"/><category term="inner join"/><category term="input"/><category term="join queries"/><category term="left outer join"/><category term="logins"/><category term="lowest"/><category term="mth to last element"/><category term="number of days"/><category term="output"/><category term="preorder"/><category term="primary key"/><category term="prime numbers"/><category term="recursion"/><category term="reverse"/><category term="right outer join"/><category term="running total"/><category term="sql server configuration"/><category term="ssis configuration"/><category term="tools"/><category term="truncate"/><category term="unique key"/><category term="variables"/><category term="without"/><title type='text'>Knowledge Base</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>63</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-5485947821764822674</id><published>2024-11-22T22:39:00.000-08:00</published><updated>2024-11-22T22:40:39.333-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="#databricks"/><category scheme="http://www.blogger.com/atom/ns#" term="#json"/><category scheme="http://www.blogger.com/atom/ns#" term="#pyspark"/><title type='text'>Processing nested json dynamically in PySpark (databricks)</title><content type='html'>&lt;p&gt;&amp;nbsp;Below youtube video provides excellent way to process complex json dynamically in PySpark (databricks)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;iframe allowfullscreen=&quot;&quot; class=&quot;BLOG_video_class&quot; height=&quot;382&quot; src=&quot;https://www.youtube.com/embed/qfJb45SusMo&quot; width=&quot;559&quot; youtube-src-id=&quot;qfJb45SusMo&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Corresponding code is in github&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/raveendratal/ravi_azureadbadf/blob/main/azure_realtime_scenarios/dynamic_json_process.ipynb&quot; target=&quot;_blank&quot;&gt;https://github.com/raveendratal/ravi_azureadbadf/blob/main/azure_realtime_scenarios/dynamic_json_process.ipynb&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/5485947821764822674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2024/11/processing-nested-json-dynamically-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5485947821764822674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5485947821764822674'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2024/11/processing-nested-json-dynamically-in.html' title='Processing nested json dynamically in PySpark (databricks)'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/qfJb45SusMo/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-1589997626079039801</id><published>2022-11-19T00:49:00.003-08:00</published><updated>2022-11-19T00:49:22.612-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="#databricks"/><category scheme="http://www.blogger.com/atom/ns#" term="#dataframe"/><category scheme="http://www.blogger.com/atom/ns#" term="#distinct"/><category scheme="http://www.blogger.com/atom/ns#" term="#dropDuplicates"/><category scheme="http://www.blogger.com/atom/ns#" term="#pyspark"/><title type='text'>How to remove Duplicates in DataFrame using PySpark</title><content type='html'>&lt;p&gt;&amp;nbsp;Below ways can be used to remove duplicates from a dataframe in PySpark:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;distinct&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.distinct()&lt;/li&gt;&lt;li&gt;df.distinct([&quot;Column1&quot;,&quot;Column2&quot;])&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;b&gt;dropDuplicates&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.dropDuplicates()&lt;/li&gt;&lt;li&gt;df.dropDuplicates([&quot;Column1&quot;,&quot;Column2&quot;])&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/1589997626079039801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-remove-duplicates-in-dataframe.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/1589997626079039801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/1589997626079039801'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-remove-duplicates-in-dataframe.html' title='How to remove Duplicates in DataFrame using PySpark'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-4132788991655199112</id><published>2022-11-18T23:47:00.001-08:00</published><updated>2022-11-18T23:55:00.023-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="#databricks"/><category scheme="http://www.blogger.com/atom/ns#" term="#dataframe"/><category scheme="http://www.blogger.com/atom/ns#" term="#orderBy"/><category scheme="http://www.blogger.com/atom/ns#" term="#pyspark"/><category scheme="http://www.blogger.com/atom/ns#" term="#python"/><category scheme="http://www.blogger.com/atom/ns#" term="#sort"/><title type='text'>How to Sort a Dataframe in PySpark</title><content type='html'>&lt;p&gt;&amp;nbsp;Below are different ways to sort a dataframe:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;sort&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.sort(df.ColumnName)&lt;/li&gt;&lt;li&gt;df.sort(df.ColumnName.desc())&lt;/li&gt;&lt;li&gt;df.sort(df.ColumnName.desc(), df.ColumnName2)&lt;/li&gt;&lt;li&gt;df.sort(col(&quot;ColumnName&quot;))&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;b&gt;orderBy&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.orderBy(df.ColumnName)&lt;/li&gt;&lt;li&gt;df.orderBy(df.ColumnName.desc())&lt;/li&gt;&lt;li&gt;df.orderBy(df.ColumnName1.desc(), df.ColumnName2)&lt;/li&gt;&lt;li&gt;df.orderBy(col(&quot;ColumnName&quot;))&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/4132788991655199112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-sort-dataframe-in-pyspark.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/4132788991655199112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/4132788991655199112'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-sort-dataframe-in-pyspark.html' title='How to Sort a Dataframe in PySpark'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-5362922056205505701</id><published>2022-11-18T23:37:00.006-08:00</published><updated>2022-11-18T23:54:32.129-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="#col"/><category scheme="http://www.blogger.com/atom/ns#" term="#databricks"/><category scheme="http://www.blogger.com/atom/ns#" term="#dataframe"/><category scheme="http://www.blogger.com/atom/ns#" term="#filter"/><category scheme="http://www.blogger.com/atom/ns#" term="#pyspark"/><category scheme="http://www.blogger.com/atom/ns#" term="#python"/><title type='text'>How to filter a DataFrame using PySpark</title><content type='html'>&lt;p&gt;&amp;nbsp;Multiple ways to filter dataframe data:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;filter&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.filter(df.ColumnName ==VALUE)&lt;/li&gt;&lt;li&gt;df.filter(col(&quot;ColumnName&quot;) == VALUE)&lt;/li&gt;&lt;li&gt;df.filter((col(&quot;ColumnName1&quot;) == VALUE) | (col(&quot;ColumnName2&quot;) == VALUE))&lt;/li&gt;&lt;li&gt;df.filter((col(&quot;ColumnName1&quot;) == VALUE) &amp;amp; (col(&quot;ColumnName2&quot;) == VALUE))&lt;/li&gt;&lt;li&gt;df.filter(col(&quot;ColumnName&quot;) != VALUE)&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/5362922056205505701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-filter-dataframe-using-pyspark.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5362922056205505701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5362922056205505701'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-filter-dataframe-using-pyspark.html' title='How to filter a DataFrame using PySpark'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-4966668512480058721</id><published>2022-11-18T22:55:00.007-08:00</published><updated>2022-11-18T23:54:08.749-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="#alias"/><category scheme="http://www.blogger.com/atom/ns#" term="#databricks"/><category scheme="http://www.blogger.com/atom/ns#" term="#dataframe"/><category scheme="http://www.blogger.com/atom/ns#" term="#lit"/><category scheme="http://www.blogger.com/atom/ns#" term="#pyspark"/><category scheme="http://www.blogger.com/atom/ns#" term="#python"/><category scheme="http://www.blogger.com/atom/ns#" term="#select"/><category scheme="http://www.blogger.com/atom/ns#" term="#withColumn"/><title type='text'>How to ADD New Columns in DataFrame using PySpark</title><content type='html'>&lt;p&gt;&amp;nbsp;Below are different ways to add new columns to dataframe in PySpark:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;withColumn and lit&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.withColumn(&quot;NewColumnName&quot;, lit(&quot;default value for new column&quot;))&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;b&gt;withColumn and col (Derived column)&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.withColumn(&quot;NewColumnName&quot;, col(&quot;Column1&quot;) * col(&quot;Column2&quot;))&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;b&gt;select&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df.select(lit(&quot;default column value&quot;).alias(&quot;NewColumnName&quot;), col(&quot;Column1&quot;), col(&quot;Column2&quot;))&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/4966668512480058721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-add-new-columns-in-dataframe.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/4966668512480058721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/4966668512480058721'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-add-new-columns-in-dataframe.html' title='How to ADD New Columns in DataFrame using PySpark'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-155654011228383108</id><published>2022-11-18T22:27:00.005-08:00</published><updated>2022-11-18T23:53:29.396-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="#col"/><category scheme="http://www.blogger.com/atom/ns#" term="#databricks"/><category scheme="http://www.blogger.com/atom/ns#" term="#dataframe"/><category scheme="http://www.blogger.com/atom/ns#" term="#pyspark"/><category scheme="http://www.blogger.com/atom/ns#" term="#select"/><category scheme="http://www.blogger.com/atom/ns#" term="#selectExpr"/><category scheme="http://www.blogger.com/atom/ns#" term="#withColumnRenamed"/><title type='text'>How to Rename columns in DataFrame using PySpark</title><content type='html'>&lt;p&gt;&amp;nbsp;There are multiple ways to rename columns in dataframe using PySpark.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;withColumnRenamed&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df = df.withColumnRenamed(&quot;Old_ColumnName1&quot;, &quot;New_ColumnName1&quot;).withColumnRenamed(&quot;Old_ColumnName2&quot;, &quot;New_ColumnName2&quot;)&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;b&gt;selectExpr&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df = df.selectExpr(&quot;Old_ColumnName1 AS NewColumnName1&quot;,&quot;Old_ColumnName2 AS NewColumnName2&quot;)&lt;/li&gt;&lt;/ol&gt;&lt;li&gt;&lt;b&gt;select(col().alias(), col())&lt;/b&gt;&lt;/li&gt;&lt;ol&gt;&lt;li&gt;df2 = df.select(col(&quot;Old_ColumnName1&quot;).alias(&quot;NewColumnName1&quot;), col(&quot;Old_ColumnName2&quot;))&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/155654011228383108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-rename-columns-in-dataframe.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/155654011228383108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/155654011228383108'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2022/11/how-to-rename-columns-in-dataframe.html' title='How to Rename columns in DataFrame using PySpark'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-6335850841674709699</id><published>2019-03-08T02:11:00.001-08:00</published><updated>2019-03-14T03:32:14.168-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><category scheme="http://www.blogger.com/atom/ns#" term="tools"/><title type='text'>Useful tools</title><content type='html'>&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;&lt;a href=&quot;https://docs.microsoft.com/en-us/sysinternals/downloads/zoomit&quot; target=&quot;_blank&quot;&gt;ZoomIt&lt;/a&gt;: ZoomIt is a screen zoom and annotation tool for technical presentations that include application demonstrations.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.devart.com/dbforge/sql/sqlcomplete/download.html&quot; target=&quot;_blank&quot;&gt;Devart SQL Complete&lt;/a&gt;: Code completion, refactoring and formatting tool.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://whoisactive.com/&quot; target=&quot;_blank&quot;&gt;sp_whoisactive&lt;/a&gt;: sp_whoisactive is a comprehensive activity monitoring stored procedure that works for all versions of SQL Server from 2005 through 2017.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.sqlskills.com/blogs/kimberly/sp_helpindex-v20170228/&quot; target=&quot;_blank&quot;&gt;sp_SQLskills_helpindex&lt;/a&gt;: Tool to get index information. sp_helpindex displays limited information. This tool displays lot of information like included columns, filters, etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;segoeui&amp;quot; , &amp;quot;segoe wp&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;segoe ui&amp;quot; , &amp;quot;segoeui&amp;quot; , &amp;quot;segoe wp&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/6335850841674709699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2019/03/useful-tools.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6335850841674709699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6335850841674709699'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2019/03/useful-tools.html' title='Useful tools'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-6822693575280459644</id><published>2018-01-22T00:31:00.000-08:00</published><updated>2019-01-18T00:13:43.184-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2016"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><category scheme="http://www.blogger.com/atom/ns#" term="Table Variables"/><category scheme="http://www.blogger.com/atom/ns#" term="Temporal Tables"/><category scheme="http://www.blogger.com/atom/ns#" term="Temporary Tables"/><title type='text'>Difference between Table Variables, Temporary Tables (Hash Tables) and Temporal Tables</title><content type='html'>&lt;script async src=&quot;//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
     (adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: &quot;ca-pub-2508014113704128&quot;,
          enable_page_level_ads: true
     });
&lt;/script&gt;
&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;u&gt;Table Variables&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Table variable is a special data type that can be used to store a result set for processing at a later time.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Table variable is primarily used for temporary storage of a set of rows returned as the result set of a table-valued function.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Functions and variables can be declared to be of type table.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Table variables can be used in functions, stored procedures, and batches.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;To declare variables of type table, use DECLARE @local_variable&lt;/li&gt;
&lt;li&gt;A table variable behaves like a local variable. It has a well-defined scope. This is the function, stored procedure, or batch that it is declared in.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Example:&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; @myTable &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Id &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;UNIQUE&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; @myTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; LastName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; @myTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; LastName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,NULL)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Fail&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; @myTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; LastName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Fail&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; @myTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; @This_Will_Not_Work &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; @myTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Only constraints allowed on the table variables are:&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Primary Key&lt;/li&gt;
&lt;li&gt;UNIQUE&lt;/li&gt;
&lt;li&gt;NULL&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Further, SELECT * INTO will not work&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;u&gt;Temporary Tables (Hash Tables)&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
There are two types of temporary tables; one is local and the other is global.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Local Temporary Tables&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Local temporary tables are the tables stored in tempdb. Local temporary tables are temporary tables that are available only to the session that created them. These tables are automatically destroyed at the termination of the procedure or session. They are specified with the prefix #, for example #table_name and these temp tables can be created with the same name in multiple windows.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Example:&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Local
temporary table&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
#myLocalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Id &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;UNIQUE&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
#myLocalTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; LastName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; #myLocalTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;VALUES &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;--Default LastName&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Global Temporary Tables&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Global temporary tables are also stored in tempdb. Global temporary tables are temporary tables that are available to all sessions and all users. They are dropped automatically when the last session using the temporary table has completed. They are specified with the prefix #, for example ##table_name.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Example:&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Global
temporary table&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
##myLocalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Id &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;UNIQUE&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DEFAULT&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
##myLocalTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; LastName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
##myLocalTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Id&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Default LastName&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/relational-databases/tables/temporal-tables&quot; target=&quot;_blank&quot;&gt;Temporal Tables&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
SQL Server 2016 introduced support for system-versioned temporal tables as a database feature that brings built-in support for providing information about data stored in the table at any point in time rather than only the data that is correct at the current moment in time.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CLUSTERED&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastName &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ValidFrom &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;datetime2&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;GENERATED&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ALWAYS&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ROW&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;START&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ValidTo &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;datetime2&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;GENERATED&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ALWAYS&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ROW&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;PERIOD&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SYSTEM_TIME &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ValidFrom&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; ValidTo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;WITH &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SYSTEM_VERSIONING&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ON &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;HISTORY_TABLE &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTableHistory&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;));&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Insert
a record&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INTO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; LastName&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Akash&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Agrawal&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Current
table will have one record. Notice the ValidFrom and ValidTo columns&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTableHistory &lt;/span&gt;&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--zero records&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Now,
update record in the table&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: magenta; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Aakash&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; ID &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Data
will be updated in current table. Notice the ValidFrom and ValidTo columns&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--History
table will have one record with ValidFrom and ValidTo columns populated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTableHistory &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Update
again&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: magenta; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; FirstName &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Aakaash&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; ID &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--Notice
multiple rows in History table&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTableHistory&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;--How to
query History data&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SYSTEM_TIME&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;BETWEEN&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;2018-01-22 08:12:26.2254807&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;2018-01-22
08:14:44.7907589&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SYSTEM_TIME&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;OF&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;2018-01-22
08:14:44.7907589&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SYSTEM_TIME&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;2018-01-22 08:12:26.2254807&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TO&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;2018-01-22
08:14:44.7907589&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SYSTEM_TIME&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CONTAINED&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;IN(&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;2018-01-22
08:12:26.2254807&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;2018-01-22 08:15:44.7907589&#39;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TemporalTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FOR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SYSTEM_TIME&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ALL&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;ORDER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;BY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; ValidFrom&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/6822693575280459644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2018/01/difference-between-table-variables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6822693575280459644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6822693575280459644'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2018/01/difference-between-table-variables.html' title='Difference between Table Variables, Temporary Tables (Hash Tables) and Temporal Tables'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-7977288613414068815</id><published>2018-01-16T00:43:00.002-08:00</published><updated>2019-01-10T01:05:50.122-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="error log"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2012"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2014"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2016"/><title type='text'>Limiting error log file size in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

It has often been observed that error logs in SQL server increase to large values. Further there is not way to set limit on size of log file from SSMS.&lt;br /&gt;
&lt;br /&gt;
Below is a very nice article to set the limits on the size of error log file along with the number of error log files.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://www.sqlskills.com/blogs/paul/limiting-error-log-file-size-in-sql-server-2012/&quot; target=&quot;_blank&quot;&gt;https://www.sqlskills.com/blogs/paul/limiting-error-log-file-size-in-sql-server-2012/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/7977288613414068815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2018/01/limiting-error-log-file-size-in-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/7977288613414068815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/7977288613414068815'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2018/01/limiting-error-log-file-size-in-sql.html' title='Limiting error log file size in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-2393353420648290915</id><published>2017-05-02T04:53:00.000-07:00</published><updated>2019-03-04T03:51:07.736-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="Performance Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="SARGABLE"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><category scheme="http://www.blogger.com/atom/ns#" term="UDF"/><title type='text'>Use of functions on indexed columns in predicates</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async=&quot;&quot; src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Use of functions on indexed columns which are used in predicates results in index not getting used for seek operation.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Use&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; tempdb&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;nocount&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;on&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;go&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: magenta; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;N&#39;Customers&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;N&#39;U&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;IS&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;TABLE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;customer_nbr &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;PRIMARY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;KEY&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;customer_name &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NOT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NULL);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;NONCLUSTERED&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INDEX&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
ix_customers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;customer_name&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Joe&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Leo&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Dave&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Lenny&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Larry&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Lefty&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&#39;Lemur&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;GO&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
If I want to write a query on this table to get all the customers whose first name starts with &#39;L&#39;.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; customer_name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;LEFT(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;customer_name&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;&#39;L&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Looking at the execution plan for above query. We can see index scan in here and not seek:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeqZF-0ARKy7pUI3U9O3-GSvd1tIsUJfF4PhWGCHf2LBoznTlSK4q2ojp-otBwp0h08JyFcfS9gZdoHux5HNE6YG7kp56wjvZ878ArvrlzOwDcU1k9w2QqdlTLsIdNiIJ2nIQ-4Jtkgsk/s1600/Before.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;128&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeqZF-0ARKy7pUI3U9O3-GSvd1tIsUJfF4PhWGCHf2LBoznTlSK4q2ojp-otBwp0h08JyFcfS9gZdoHux5HNE6YG7kp56wjvZ878ArvrlzOwDcU1k9w2QqdlTLsIdNiIJ2nIQ-4Jtkgsk/s640/Before.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, what if we rewrite this query without the use of LEFT function as below:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; customer_name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; dbo&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;Customers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; customer_name &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;LIKE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;&#39;L%&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt; line-height: 107%;&quot;&gt;;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Looking at the execution plan for above query shows us index seek and the output of query is same as before.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjBgn3Y_1Sx77L-0TfhoW09HYG1QXbtA6ftKc_pQNq06psUZJc3TXHDvXCVR_fPGQG0hlO4PJd8qiWgL019K70ahQjcdBzqvEeJme8DBj5cFkr3zN_iiRmhyphenhyphenT_irigeOKCM_57i3_t2do/s1600/After.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;122&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjBgn3Y_1Sx77L-0TfhoW09HYG1QXbtA6ftKc_pQNq06psUZJc3TXHDvXCVR_fPGQG0hlO4PJd8qiWgL019K70ahQjcdBzqvEeJme8DBj5cFkr3zN_iiRmhyphenhyphenT_irigeOKCM_57i3_t2do/s640/After.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Functions on indexed column used in predicates makes them non-sargable and impacts performance.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Reference:&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
https://sqlbits.com/Sessions/Event14/Common_TSQL_Mistakes&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/2393353420648290915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2017/05/use-of-functions-on-indexed-columns-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2393353420648290915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2393353420648290915'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2017/05/use-of-functions-on-indexed-columns-in.html' title='Use of functions on indexed columns in predicates'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeqZF-0ARKy7pUI3U9O3-GSvd1tIsUJfF4PhWGCHf2LBoznTlSK4q2ojp-otBwp0h08JyFcfS9gZdoHux5HNE6YG7kp56wjvZ878ArvrlzOwDcU1k9w2QqdlTLsIdNiIJ2nIQ-4Jtkgsk/s72-c/Before.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-560771965260071952</id><published>2017-03-10T01:28:00.001-08:00</published><updated>2019-03-04T03:50:45.822-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Performance Optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>SQL Server important links</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async=&quot;&quot; src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Joins&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://www.techonthenet.com/sql_server/joins.php&quot; target=&quot;_blank&quot;&gt;https://www.techonthenet.com/sql_server/joins.php&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Indexes&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://www.simple-talk.com/sql/learn-sql-server/sql-server-index-basics/&quot; target=&quot;_blank&quot;&gt;https://www.simple-talk.com/sql/learn-sql-server/sql-server-index-basics/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Index seek, scan, lookup and others in execution plan&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://www.simple-talk.com/sql/performance/identifying-and-solving-index-scan-problems/&quot; target=&quot;_blank&quot;&gt;https://www.simple-talk.com/sql/performance/identifying-and-solving-index-scan-problems/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Temporary tables vs table variables&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://www.mssqltips.com/sqlservertip/2825/sql-server-temp-table-vs-table-variable-performance-testing/&quot; target=&quot;_blank&quot;&gt;https://www.mssqltips.com/sqlservertip/2825/sql-server-temp-table-vs-table-variable-performance-testing/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;SARGable expressions&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://sqlsunday.com/2014/01/19/sargable-expression-performance/&quot; target=&quot;_blank&quot;&gt;https://sqlsunday.com/2014/01/19/sargable-expression-performance/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://datatellblog.wordpress.com/2016/11/24/sql-server-query-optimization-sargable-functions/&quot; target=&quot;_blank&quot;&gt;https://datatellblog.wordpress.com/2016/11/24/sql-server-query-optimization-sargable-functions/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://datatellblog.wordpress.com/2016/11/24/sql-server-query-optimization-sargable-functions/&quot; target=&quot;_blank&quot;&gt;https://datatellblog.wordpress.com/2016/11/24/sql-server-query-optimization-sargable-functions/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/560771965260071952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2017/03/sql-server-important-links.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/560771965260071952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/560771965260071952'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2017/03/sql-server-important-links.html' title='SQL Server important links'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-3914635069492225684</id><published>2017-01-24T01:30:00.002-08:00</published><updated>2019-01-10T01:06:54.829-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><category scheme="http://www.blogger.com/atom/ns#" term="XML"/><title type='text'>Store and retrieve data into XML from table in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

The aim of this post is to store data in a table in the form of XML along with schema, and to retrieve the same from XML in a tabular structure.&lt;br /&gt;
&lt;br /&gt;
Let us take an example of a table say Employee:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; Employee&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID &lt;span style=&quot;color: blue;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FName &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;200&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LNAME &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;200&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Salary &lt;span style=&quot;color: blue;&quot;&gt;FLOAT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;INTO&lt;/span&gt; Employee&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;ID&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; FName&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; LName&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; Salary&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;1&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;A&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;10.1&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;2&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;C&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;D&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;12.123&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;3&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;E&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;F&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;123.13&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@xml &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@xml &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FName&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LName&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Salary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt;
Employee&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FOR&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AUTO&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;ELEMENTS&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;XMLSCHEMA&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;AnySchema&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;ROOT&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Root&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@xml&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This is how Table can be stored in XML format along with schema. If you see the output XML, it will have two portions, one with schema and another with actual data.&lt;br /&gt;
&lt;br /&gt;
Below, is how we can get back the data from XML into tabular structure.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@XSD &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; @sql &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt; @TableName &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;100&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@XSD &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;query&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;.&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt; @XML&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;nodes&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;/Root/*[1]&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; a&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XML &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;STUFF&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@XML&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;query&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;*[1]/*&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;
1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;CHARINDEX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: red;&quot;&gt;&#39;&amp;lt;/xsd:schema&amp;gt;&#39;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@XML&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;query&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;*[1]/*&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; 12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FOR&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;RAW &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Root&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XML &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@XML &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)),&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;
xmlns=&quot;AnySchema&quot;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @TableName &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;
a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;value&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;@name&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;varchar(100)&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@XSD&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;nodes&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;/*/*&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; a&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XSD &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;query&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;.&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt;
@XSD&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;nodes&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;/*/*[2]/*/*&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; a&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XSD &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@XSD &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)),&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;p1:&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@XSD &lt;span style=&quot;color: grey;&quot;&gt;IS&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;BEGIN&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: red;&quot;&gt;&#39;XML Schema was
not specified&#39;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;RETURN&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;END&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;EXISTS&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt;
Tempdb&lt;span style=&quot;color: grey;&quot;&gt;..&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;sysobjects&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Tempdb..#TableDefinition&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; #TableDefinition&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; #TableDefinition&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID &lt;span style=&quot;color: blue;&quot;&gt;INT&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;IDENTITY&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;1&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;1&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnName &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;255&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnDataType1 &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;255&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnDataType2 &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;255&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ColumnDataType2Length &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;255&lt;span style=&quot;color: grey;&quot;&gt;),&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hasLength &lt;span style=&quot;color: blue;&quot;&gt;INT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;INTO&lt;/span&gt; #TableDefinition&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;value&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;@name&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;varchar(100)&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;
ColumnName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;value&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;@type&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;sysname&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;100&lt;span style=&quot;color: grey;&quot;&gt;)),&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;sqltypes:&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; ColumnDataType1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;value&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;*[1]/*[1]/@base&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;sysname&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;100&lt;span style=&quot;color: grey;&quot;&gt;)),&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;sqltypes:&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; ColumnDataType2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;REPLACE&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;a&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;value&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;*[1]/*[1]/*[1]/@value&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;sysname&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;100&lt;span style=&quot;color: grey;&quot;&gt;)),&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;sqltypes:&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; ColumnDataType2Length&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;0
&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; hasLength&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt;
@XSD&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;nodes&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;/*/*&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; a&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;x&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: magenta; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;UPDATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
#TableDefinition&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hasLength &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;
1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;ColumnDataType2Length
&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;CASE&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;WHEN&lt;/span&gt;
ColumnDataType2 &lt;span style=&quot;color: grey;&quot;&gt;IN&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;numeric&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;decimal&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;THEN&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;RTRIM&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;ColumnDataType2Length&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;,10&#39;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;ELSE&lt;/span&gt;
ColumnDataType2Length&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
ColumnDataType2Length &lt;span style=&quot;color: grey;&quot;&gt;IS&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;NULL&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@TableDefinition &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;
@TableDefinition &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: magenta;&quot;&gt;CAST&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;CASE&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;WHEN&lt;/span&gt;
hasLength &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; 1 &lt;span style=&quot;color: blue;&quot;&gt;THEN&lt;/span&gt;
ColumnName &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39; &#39;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; ColumnDataType2 &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt;&#39;(&#39;&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt;
ColumnDataType2Length &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;),&#39;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;ELSE&lt;/span&gt;
ColumnName &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39; &#39;&lt;/span&gt;
&lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; ColumnDataType1 &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt;&#39;,&#39;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt;
#TableDefinition a&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FOR&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;PATH &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @TableDefinition &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;SUBSTRING&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@TableDefinition&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; 0&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;LEN&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;@TableDefinition&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;IF&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;EXISTS&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt;
Tempdb&lt;span style=&quot;color: grey;&quot;&gt;..&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;sysobjects&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Tempdb..#XML&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;DROP&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; #XML&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @XML &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt;
XMLDATA &lt;span style=&quot;color: blue;&quot;&gt;INTO&lt;/span&gt; #XML&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @sql &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: red;&quot;&gt;&#39; DECLARE @handle
INT, @PrepareXMLStatus INT, @XML2 XML&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp; SET @XML2 = (SELECT XMLDATA FROM #XML);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp; EXEC @PrepareXMLStatus =
sp_xml_preparedocument @handle OUTPUT, @XML2;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp; SELECT *&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp; FROM OPENXML(@handle, &#39;&#39;/Root/&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; @TableName &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&#39;, 2)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WITH (&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; @TableDefinition &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: red; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&amp;nbsp; EXEC sp_xml_removedocument @handle;&#39;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;EXEC &lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;consolas&amp;quot;; font-size: 9.5pt;&quot;&gt;@sql&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/3914635069492225684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2017/01/store-and-retrieve-data-into-xml-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/3914635069492225684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/3914635069492225684'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2017/01/store-and-retrieve-data-into-xml-from.html' title='Store and retrieve data into XML from table in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-5837454188699507281</id><published>2017-01-24T01:27:00.002-08:00</published><updated>2019-01-10T01:07:06.519-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>Remove specific plan for procedure or query from the cache in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;--Find
the plan handle by providing the procedure name&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;
plan_handle&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; st&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;,*&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;dm_exec_cached_plans&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;CROSS&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;APPLY&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;dm_exec_sql_text&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;plan_handle&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; st&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;objtype &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;Proc&#39;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;LIKE&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;N&#39;%zz_%&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;;&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;-- Remove
the specific plan from the cache.&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;DBCC&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: Consolas;&quot;&gt;
FREEPROCCACHE&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;0x05000600D1D5E903F057B85B0400000001000000000000000000000000000000000000000000000000000000&lt;span style=&quot;color: grey;&quot;&gt;);&lt;/span&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/5837454188699507281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2017/01/remove-specific-plan-for-procedure-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5837454188699507281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5837454188699507281'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2017/01/remove-specific-plan-for-procedure-or.html' title='Remove specific plan for procedure or query from the cache in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-7105523003543658511</id><published>2015-03-11T09:05:00.000-07:00</published><updated>2019-01-18T00:15:21.618-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>Implicit data conversion</title><content type='html'>&lt;script async src=&quot;//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
     (adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: &quot;ca-pub-2508014113704128&quot;,
          enable_page_level_ads: true
     });
&lt;/script&gt;
&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

This is one thing that I didn&#39;t knew happened in SQL Server.&lt;br /&gt;
&lt;br /&gt;
When integers are implicitly converted to a character data type, if the integer is too large to fit into the character field, SQL Server enters ASCII character 42, the asterisk (*).&lt;br /&gt;
&lt;br /&gt;
If we look at below example, when integer 123 is inserted it is implicitly converted to VARCHAR successfully. But, when value with length greater than 3 is inserted, asterisk is inserted instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwnEt8oKaLv_WXuBo6jEMFgBYdwKzRcsMtpN7NjNXkqwy_ajY2eYk_4e7t1t5K471DWBa1IHC-d43VaB39URbf5oB9LvysDhDYWK-AaJPF53Y2aBflytzKQ3qzHclU5qWgtB9T7MJRUuM/s1600/0.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwnEt8oKaLv_WXuBo6jEMFgBYdwKzRcsMtpN7NjNXkqwy_ajY2eYk_4e7t1t5K471DWBa1IHC-d43VaB39URbf5oB9LvysDhDYWK-AaJPF53Y2aBflytzKQ3qzHclU5qWgtB9T7MJRUuM/s1600/0.png&quot; height=&quot;350&quot; width=&quot;400&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/7105523003543658511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2015/03/implicit-data-conversion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/7105523003543658511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/7105523003543658511'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2015/03/implicit-data-conversion.html' title='Implicit data conversion'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwnEt8oKaLv_WXuBo6jEMFgBYdwKzRcsMtpN7NjNXkqwy_ajY2eYk_4e7t1t5K471DWBa1IHC-d43VaB39URbf5oB9LvysDhDYWK-AaJPF53Y2aBflytzKQ3qzHclU5qWgtB9T7MJRUuM/s72-c/0.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-8621023991636371219</id><published>2013-06-26T00:48:00.005-07:00</published><updated>2019-01-10T01:08:02.311-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Find a job with a particular text in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Find a job in SQL Server with a particular text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;USE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; [msdb]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;job_id&lt;span style=&quot;color: grey;&quot;&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;srvname&lt;span style=&quot;color: grey;&quot;&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;name&lt;span style=&quot;color: grey;&quot;&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; js&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;step_id&lt;span style=&quot;color: grey;&quot;&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; js&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;command&lt;span style=&quot;color: grey;&quot;&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;enabled&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; dbo&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;sysjobs j&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; dbo&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;sysjobsteps js&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt;&amp;nbsp;&amp;nbsp; js&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;job_id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; j&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;job_id &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;JOIN&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;master&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;dbo&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;sysservers&lt;/span&gt; s&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt;&amp;nbsp;&amp;nbsp; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;srvid &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; j&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;originating_server_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; js&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;command &lt;span style=&quot;color: grey;&quot;&gt;LIKE&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;N&#39;%text to search in job%&#39;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/8621023991636371219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2013/06/find-job-in-sql-server-job.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/8621023991636371219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/8621023991636371219'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2013/06/find-job-in-sql-server-job.html' title='Find a job with a particular text in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-6043381889316958744</id><published>2013-06-26T00:42:00.002-07:00</published><updated>2019-01-10T01:08:13.263-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>Get comma separated values from table grouped by particular column</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Suppose we have a table&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;TABLE&lt;/span&gt; #temp&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID &lt;span style=&quot;color: blue;&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name &lt;span style=&quot;color: blue;&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;100&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;INSERT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;INTO&lt;/span&gt; #temp&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;ID&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;name&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;VALUES&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;1&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Akash&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;1&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;B&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;1&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;C&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;2&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;AA&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;2&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;BB&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
We want to get the names as comma separated grouped by ID, so for ID 1 we will have &#39;Akash, B, C&#39;. Below query will create a comma separated list grouped by ID.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;select&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;distinct&lt;/span&gt; u1&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;ID&lt;span style=&quot;color: grey;&quot;&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: magenta;&quot;&gt;Replace&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;select&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;distinct&lt;/span&gt; u2&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;name &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;,&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;data()&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; #temp u2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; u2&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;ID &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; u1&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;FOR&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;XML&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;PATH&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;$&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;,$&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; Names&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; #temp u1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;order&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;by&lt;/span&gt; u1&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;ID&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/6043381889316958744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2013/06/get-comma-separated-values-from-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6043381889316958744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6043381889316958744'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2013/06/get-comma-separated-values-from-table.html' title='Get comma separated values from table grouped by particular column'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-6673346300864261223</id><published>2013-06-26T00:35:00.004-07:00</published><updated>2019-01-10T01:08:22.775-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>Clear Plans for particular type of object in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;-- clear plans for a particular
type of object&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;-- clear sql plans: adhoc sql,
prepared statements&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;dbcc&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; freesystemcache&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;SQL Plans&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;-- clear object plans: stored
procedures, functions, triggers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;dbcc&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; freesystemcache&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Object Plans&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;-- clear bound trees: views,
constraints, defaults&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;dbcc&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; freesystemcache&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Bound Trees&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: green; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;-- clear extended stored procedures&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;dbcc&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; freesystemcache&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;Extended
Stored Procedures&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/6673346300864261223/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2013/06/clear-plans-for-particular-type-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6673346300864261223'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6673346300864261223'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2013/06/clear-plans-for-particular-type-of.html' title='Clear Plans for particular type of object in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-3505132725038362869</id><published>2013-06-26T00:34:00.000-07:00</published><updated>2019-01-10T01:08:35.162-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>Find all the stored procedures with particular text..</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Below query will help find all the stored procedures with a particular text. System table syscomments contains the text of stored procedure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;DECLARE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; @StringToSearch &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;500&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;SET&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; @StringToSearch &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt;&#39;%text in stored procedure%&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;Distinct&lt;/span&gt; SO&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: green;&quot;&gt;sysobjects&lt;/span&gt; SO&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;NOLOCK&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;INNER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;JOIN&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;syscomments&lt;/span&gt; SC&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;NOLOCK&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;on&lt;/span&gt; SO&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;Id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; SC&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; SO&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Type&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;P&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; SC&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Text&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;LIKE&lt;/span&gt;
@stringtosearch&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt;ORDER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;BY&lt;/span&gt; SO&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/3505132725038362869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2013/06/find-all-stored-procedures-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/3505132725038362869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/3505132725038362869'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2013/06/find-all-stored-procedures-with.html' title='Find all the stored procedures with particular text..'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-2576981604959281594</id><published>2012-12-21T07:36:00.000-08:00</published><updated>2019-01-10T01:08:47.544-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="indexes"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>Find Indexes Not In Use in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

We found out that we have lot of indexes on our tables which were not of any use and hence needed to be removed. Found this &lt;a href=&quot;http://sqlserverpedia.com/wiki/Find_Indexes_Not_In_Use&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;&amp;nbsp;that does the same.&amp;nbsp;Below query helps to find out indexes which have not been used since last restart.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;o&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; indexname&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;index_id&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; reads&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;user_seeks &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt;
user_scans &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; user_lookups&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; writes &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&amp;nbsp;
user_updates&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;rows&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;p&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;rows&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;partitions&lt;/span&gt; p &lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; p&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;index_id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;index_id &lt;span style=&quot;color: grey;&quot;&gt;AND&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; p&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;CASE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;WHEN&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;user_updates
&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt; 1 &lt;span style=&quot;color: blue;&quot;&gt;THEN&lt;/span&gt; 100&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;ELSE&lt;/span&gt; 1.00 &lt;span style=&quot;color: grey;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;user_seeks &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;user_scans &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;user_lookups&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;/&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;user_updates&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; reads_per_write&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;DROP INDEX &#39;&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;QUOTENAME&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;name&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39; ON &#39;&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;QUOTENAME&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;c&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;name&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;.&#39;&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;QUOTENAME&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;OBJECT_NAME&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;))&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;drop statement&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;dm_db_index_usage_stats&lt;/span&gt; s&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;INNER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;JOIN&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;indexes&lt;/span&gt; i &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt; i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;index_id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;index_id &lt;span style=&quot;color: grey;&quot;&gt;AND&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;INNER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;JOIN&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;objects&lt;/span&gt; o &lt;span style=&quot;color: blue;&quot;&gt;on&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; o&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;INNER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;JOIN&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;schemas&lt;/span&gt; c &lt;span style=&quot;color: blue;&quot;&gt;on&lt;/span&gt; o&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;schema_id&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; c&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;schema_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: magenta;&quot;&gt;OBJECTPROPERTY&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&#39;IsUserTable&#39;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;database_id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: magenta;&quot;&gt;DB_ID&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;()&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;type_desc &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;&#39;nonclustered&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;is_primary_key &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; i&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;is_unique_constraint &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;
0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: magenta;&quot;&gt;SUM&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(&lt;/span&gt;p&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;rows&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;partitions&lt;/span&gt; p &lt;span style=&quot;color: blue;&quot;&gt;WHERE&lt;/span&gt; p&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;index_id &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;index_id &lt;span style=&quot;color: grey;&quot;&gt;AND&lt;/span&gt; s&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; p&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt; 10000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt;ORDER&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-no-proof: yes;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;BY&lt;/span&gt; reads&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/2576981604959281594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2012/12/find-indexes-not-in-use-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2576981604959281594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2576981604959281594'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2012/12/find-indexes-not-in-use-in-sql-server.html' title='Find Indexes Not In Use in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-7987664443580790565</id><published>2012-12-21T07:27:00.001-08:00</published><updated>2019-01-10T01:08:58.793-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="logins"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>How to script SQL Server Logins</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Every now and then you add new instance you have to create logins on new server which are exact replica of some existing server. In that case it is tedious to create logins manually and a script that would do the job would be great.&lt;br /&gt;
&lt;br /&gt;
I found a great &lt;a href=&quot;http://weblogs.sqlteam.com/billg/archive/2010/07/08/Scripting-out-SQL-Server-Logins.aspx&quot; target=&quot;_blank&quot;&gt;script&lt;/a&gt;&amp;nbsp;which does the same. Below is the script copied from the link. It is of great help.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre id=&quot;codeSnippet&quot; style=&quot;background-color: #f4f4f4; border-style: none; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; white-space: pre-wrap; width: 789px; word-wrap: break-word;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;USE&lt;/span&gt; [master]
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;

&lt;span style=&quot;color: green;&quot;&gt;/****** Object:  UserDefinedFunction [dbo].[fn_hexadecimal]    ****/&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;FUNCTION&lt;/span&gt; [dbo].[fn_hexadecimal] 
(
    &lt;span style=&quot;color: green;&quot;&gt;-- Add the parameters for the function here&lt;/span&gt;
     @binvalue varbinary(256)
)
&lt;span style=&quot;color: blue;&quot;&gt;RETURNS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;(256)
&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;BEGIN&lt;/span&gt;

    &lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt; @charvalue &lt;span style=&quot;color: blue;&quot;&gt;varchar&lt;/span&gt;(256)
    &lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt; @i &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt; @length &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt; @hexstring &lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;(16)
    &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @charvalue = &lt;span style=&quot;color: #006080;&quot;&gt;&#39;0x&#39;&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @i = 1
    &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @length = DATALENGTH (@binvalue)
    &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @hexstring = &lt;span style=&quot;color: #006080;&quot;&gt;&#39;0123456789ABCDEF&#39;&lt;/span&gt; 
    &lt;span style=&quot;color: blue;&quot;&gt;WHILE&lt;/span&gt; (@i &amp;lt;= @length) 
    &lt;span style=&quot;color: blue;&quot;&gt;BEGIN&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt; @tempint &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt; @firstint &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;DECLARE&lt;/span&gt; @secondint &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
      &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @tempint = &lt;span style=&quot;color: blue;&quot;&gt;CONVERT&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;, &lt;span style=&quot;color: blue;&quot;&gt;SUBSTRING&lt;/span&gt;(@binvalue,@i,1))
      &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @firstint = FLOOR(@tempint/16)
      &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @secondint = @tempint - (@firstint*16)
      &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @charvalue = @charvalue +
        &lt;span style=&quot;color: blue;&quot;&gt;SUBSTRING&lt;/span&gt;(@hexstring, @firstint+1, 1) +
        &lt;span style=&quot;color: blue;&quot;&gt;SUBSTRING&lt;/span&gt;(@hexstring, @secondint+1, 1)
      &lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; @i = @i + 1
    &lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt;
    &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; @charvalue

&lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;


&lt;span style=&quot;color: blue;&quot;&gt;SET&lt;/span&gt; NOCOUNT &lt;span style=&quot;color: blue;&quot;&gt;ON&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;
--&lt;span style=&quot;color: blue;&quot;&gt;use&lt;/span&gt; MASTER
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-- Script created on &#39;&lt;/span&gt; + &lt;span style=&quot;color: blue;&quot;&gt;CAST&lt;/span&gt;(GETDATE() &lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;VARCHAR&lt;/span&gt;(100))
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-- Create the windows logins&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;IF NOT EXISTS (SELECT * FROM master.sys.server_principals WHERE [name] = &#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt; + [name] + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;)
    CREATE LOGIN [&#39;&lt;/span&gt; + [name] + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;] FROM WINDOWS WITH DEFAULT_DATABASE=[&#39;&lt;/span&gt; + 
        default_database_name + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;], DEFAULT_LANGUAGE=[us_english]
GO

&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;FROM&lt;/span&gt; master.sys.server_principals
&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; type_desc &lt;span style=&quot;color: blue;&quot;&gt;In&lt;/span&gt; (&lt;span style=&quot;color: #006080;&quot;&gt;&#39;WINDOWS_GROUP&#39;&lt;/span&gt;, &lt;span style=&quot;color: #006080;&quot;&gt;&#39;WINDOWS_LOGIN&#39;&lt;/span&gt;)
&lt;span style=&quot;color: blue;&quot;&gt;AND&lt;/span&gt; [name] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;like&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;BUILTIN%&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;and&lt;/span&gt; [NAME] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;like&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;NT AUTHORITY%&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;and&lt;/span&gt; [name] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;like&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;%\SQLServer%&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;GO&lt;/span&gt;

&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-- Create the SQL Logins&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;select&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;IF NOT EXISTS (SELECT * FROM master.sys.sql_logins WHERE [name] = &#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt; + [name] + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;)
    CREATE LOGIN [&#39;&lt;/span&gt; + [name] + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;] 
        WITH PASSWORD=&#39;&lt;/span&gt; + [master].[dbo].[fn_hexadecimal](password_hash) + &lt;span style=&quot;color: #006080;&quot;&gt;&#39; HASHED,
        SID = &#39;&lt;/span&gt; + [master].[dbo].[fn_hexadecimal]([sid]) + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;,  
        DEFAULT_DATABASE=[&#39;&lt;/span&gt; + default_database_name + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;], DEFAULT_LANGUAGE=[us_english], 
        CHECK_EXPIRATION=&#39;&lt;/span&gt; + &lt;span style=&quot;color: blue;&quot;&gt;CASE&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;WHEN&lt;/span&gt; is_expiration_checked = 1 &lt;span style=&quot;color: blue;&quot;&gt;THEN&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;ON&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;ELSE&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;OFF&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt; + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;, CHECK_POLICY=OFF
GO
IF EXISTS (SELECT * FROM master.sys.sql_logins WHERE [name] = &#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt; + [name] + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;)
    ALTER LOGIN [&#39;&lt;/span&gt; + [name] + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;]
        WITH CHECK_EXPIRATION=&#39;&lt;/span&gt; + 
            &lt;span style=&quot;color: blue;&quot;&gt;CASE&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;WHEN&lt;/span&gt; is_expiration_checked = 1 &lt;span style=&quot;color: blue;&quot;&gt;THEN&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;ON&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;ELSE&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;OFF&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt; + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;, CHECK_POLICY=&#39;&lt;/span&gt; + 
            &lt;span style=&quot;color: blue;&quot;&gt;CASE&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;WHEN&lt;/span&gt; is_policy_checked = 1 &lt;span style=&quot;color: blue;&quot;&gt;THEN&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;ON&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;ELSE&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;OFF&#39;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;END&lt;/span&gt; + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;
GO


&#39;&lt;/span&gt;
--[name], [sid] , password_hash 
&lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; master.sys.sql_logins 
&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; type_desc = &lt;span style=&quot;color: #006080;&quot;&gt;&#39;SQL_LOGIN&#39;&lt;/span&gt; 
&lt;span style=&quot;color: blue;&quot;&gt;and&lt;/span&gt; [name] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; (&lt;span style=&quot;color: #006080;&quot;&gt;&#39;sa&#39;&lt;/span&gt;, &lt;span style=&quot;color: #006080;&quot;&gt;&#39;guest&#39;&lt;/span&gt;)

&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-- Disable any logins&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;ALTER LOGIN [&#39;&lt;/span&gt; + [name] + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;] DISABLE
GO
&#39;&lt;/span&gt; 
&lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; master.sys.server_principals 
&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; is_disabled = 1

&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-- Assign groups&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;PRINT&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;-----------------------------------------------------------------------------&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;select&lt;/span&gt; 
&lt;span style=&quot;color: #006080;&quot;&gt;&#39;EXEC master..sp_addsrvrolemember @loginame = N&#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt; + l.name + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;, @rolename = N&#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt; + r.name + &lt;span style=&quot;color: #006080;&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span style=&quot;color: #006080;&quot;&gt;&#39;
GO

&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; master.sys.server_role_members rm
&lt;span style=&quot;color: blue;&quot;&gt;join&lt;/span&gt; master.sys.server_principals r &lt;span style=&quot;color: blue;&quot;&gt;on&lt;/span&gt; r.principal_id = rm.role_principal_id
&lt;span style=&quot;color: blue;&quot;&gt;join&lt;/span&gt; master.sys.server_principals l &lt;span style=&quot;color: blue;&quot;&gt;on&lt;/span&gt; l.principal_id = rm.member_principal_id
&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; l.[name] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; (&lt;span style=&quot;color: #006080;&quot;&gt;&#39;sa&#39;&lt;/span&gt;)
&lt;span style=&quot;color: blue;&quot;&gt;AND&lt;/span&gt; l.[name] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;like&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;BUILTIN%&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;and&lt;/span&gt; l.[NAME] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;like&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;NT AUTHORITY%&#39;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;and&lt;/span&gt; l.[name] &lt;span style=&quot;color: blue;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;like&lt;/span&gt; &lt;span style=&quot;color: #006080;&quot;&gt;&#39;%\SQLServer%&#39;&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/7987664443580790565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2012/12/how-to-script-sql-server-logins.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/7987664443580790565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/7987664443580790565'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2012/12/how-to-script-sql-server-logins.html' title='How to script SQL Server Logins'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-2134656307456686992</id><published>2012-07-16T02:36:00.001-07:00</published><updated>2019-01-10T01:09:08.966-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Who is Active? DMV Monitoring tool</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Here is the link for the very important tool that you need to know what is running on your SQL Server... Tool is developed by Adam Machanic... &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://sqlblog.com/blogs/adam_machanic/archive/2010/10/21/who-is-active-v10-00-dmv-monitoring-made-easy.aspx&quot;&gt;&lt;br /&gt;
http://sqlblog.com/blogs/adam_machanic/archive/2010/10/21/who-is-active-v10-00-dmv-monitoring-made-easy.aspx&lt;br /&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/2134656307456686992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2012/07/who-is-active-dmv-monitoring-tool.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2134656307456686992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2134656307456686992'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2012/07/who-is-active-dmv-monitoring-tool.html' title='Who is Active? DMV Monitoring tool'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-5968503297614554482</id><published>2012-05-24T19:53:00.000-07:00</published><updated>2019-01-10T01:09:24.183-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><category scheme="http://www.blogger.com/atom/ns#" term="Table Partition"/><title type='text'>How to Partition a Table in SQL Server..</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

&lt;b&gt;What is Table Partitioning?&lt;/b&gt;&lt;br /&gt;
Table partitioning is built-in method of horizontally &amp;nbsp;partitioning data within a table and/or index still maintaining the table as a single logical object. &amp;nbsp;Partitioning keeps the same no of columns in each partition, but reducing the number of rows.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Why do we need Table Partitioning?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
- Easy management of large tables and indexes.&lt;br /&gt;
- Decrease load time.&lt;br /&gt;
- Improve query performance.&lt;br /&gt;
- Provide small window for maintenance, means easy to maintain chunks of data instead of whole.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How Partitioning is done?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
- Create file -groups to hold the partitions.&lt;br /&gt;
- Add files to each file -group in the partitioning.&lt;br /&gt;
- Create Partition Function.&lt;br /&gt;
- Create Partition Scheme.&lt;br /&gt;
- Create table , binding &amp;nbsp;a specific column to a &amp;nbsp;Partition Scheme.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
Below is an example of partitioning a table:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Create a sample database to be used for partitioning. I have added two file groups other than the primary file group to it.&lt;/div&gt;

&lt;pre class=&quot;brush: sql&quot;&gt;
CREATE DATABASE [PartitionDB] ON
PRIMARY
      (     NAME = N&#39;PartitionDB&#39;,
            FILENAME = N&#39;C:\PartitionDB\PartitionDB.mdf&#39; ,
            SIZE = 3072KB , FILEGROWTH = 1024KB
      ),
FILEGROUP [FG2]
      (     NAME = N&#39;PartitionDB_2&#39;,
            FILENAME = N&#39;C:\PartitionDB\PartitionDB_2.ndf&#39; ,
            SIZE = 3072KB , FILEGROWTH = 1024KB
      )
FILEGROUP [FG3]
      (     NAME = N&#39;PartitionDB_3&#39;,
            FILENAME = N&#39;C:\PartitionDB\PartitionDB_3.ndf&#39; ,
            SIZE = 3072KB , FILEGROWTH = 1024KB
      )
LOG ON
      (     NAME = N&#39;PartitionDB_log&#39;,
            FILENAME = N&#39;C:\PartitionDB\PartitionDB_log.ldf&#39; ,
            SIZE = 9216KB , FILEGROWTH = 10%
      )
&lt;/pre&gt;

&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;Now we create a Partition Function. Partition Function can be used for any Partition Scheme. Please read the below link for specific details about the partition function:&lt;/o:p&gt;&lt;/div&gt;

&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms187802(v=sql.105).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms187802(v=sql.105).aspx&lt;/a&gt;
&lt;/o:p&gt;&lt;/div&gt;

&lt;pre class=&quot;brush: sql&quot;&gt;
CREATE PARTITION FUNCTION EqualFunc (INT)
AS RANGE LEFT
FOR VALUES (0,1)
&lt;/pre&gt;


&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;Next step is to create a Partition Scheme. Here is the link for Partition Scheme:&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms179854(v=sql.105).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms179854(v=sql.105).aspx&lt;/a&gt;
&lt;/o:p&gt;&lt;/div&gt;

&lt;pre class=&quot;brush: sql&quot;&gt;
CREATE PARTITION SCHEME EqualScheme
AS PARTITION EqualFunc
TO (FG2, FG3, [PRIMARY])
&lt;/pre&gt;

&lt;br /&gt;
&lt;br /&gt;
Finally we create a table using the Partition Scheme that we created. Based on the value of ID column PartitionElement will be computed and that will be used in deciding on which file group the row will be stored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: sql&quot;&gt;
CREATE TABLE Customer
(
      ID     INT,
      Name        VARCHAR(20),
      PartitionElement AS ID % 3 PERSISTED
)
ON EqualScheme (PartitionElement)

INSERT INTO Customer(ID,Name) VALUES(3,&#39;abc3&#39;)
INSERT INTO Customer(ID,Name) VALUES(1,&#39;abc1&#39;)
INSERT INTO Customer(ID,Name) VALUES(2,&#39;abc2&#39;)
&lt;/pre&gt;

&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
Below query will determine the rows in each partition that is created for the table.&lt;/div&gt;
&lt;pre class=&quot;brush: sql&quot;&gt;
SELECT partition_id, object_id, partition_number, rows
FROM sys.partitions
WHERE object_id = OBJECT_ID(&#39;Customer&#39;)
&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
If we want to get the resultset for the particular partition here is the query&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: sql&quot;&gt;
SELECT *
FROM  Customer
WHERE $PARTITION.EqualFunc(PartitionElement) = 2
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;
It is advisable to keep the filegroups on different disk drives for parallelism.&amp;nbsp;Partitioning is a great way to improve performance for the tables with large amount of data.&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/5968503297614554482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2012/05/how-to-partition-table-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5968503297614554482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/5968503297614554482'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2012/05/how-to-partition-table-in-sql-server.html' title='How to Partition a Table in SQL Server..'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-6570835467205864794</id><published>2012-05-05T22:18:00.003-07:00</published><updated>2019-01-18T00:15:38.199-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="Max Server Memory"/><category scheme="http://www.blogger.com/atom/ns#" term="Memory Behavior"/><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Memory Behavior in SQL Server</title><content type='html'>&lt;script async src=&quot;//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
     (adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: &quot;ca-pub-2508014113704128&quot;,
          enable_page_level_ads: true
     });
&lt;/script&gt;
&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Memory behavior of SQL Server 2008 is very different from SQL Server 2005. On observing the memory utilization of the server on which SQL Server was installed we found that SQL Server takes up all the memory that is available. But we were not completely right. By doing some research I came up with below summary:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;“&lt;span style=&quot;background: none repeat scroll 0% 0% white; color: black;&quot;&gt;When you start SQL Server, SQL Server
memory usage may continue to steadily increase and not decrease, even when
activity on the server is low. Additionally, the Task Manager and Performance
Monitor may show that the physical memory available on the computer is steadily
decreasing until the available memory is between 4 to 10 MB.This behavior alone
does not indicate a memory leak. This behavior is normal and is an intended
behavior of the SQL Server buffer pool.&lt;/span&gt;”&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;“&lt;span style=&quot;background: none repeat scroll 0% 0% white; color: black;&quot;&gt;By default, SQL Server dynamically grows
and shrinks the size of its buffer pool (cache) depending on the physical
memory load reported by the operating system. As long as enough memory is
available to prevent paging (between 4 - 10 MB), the SQL Server buffer pool
will continue to grow. As other processes on the same computer as SQL Server
allocate memory, the SQL Server buffer manager will release memory as needed.
SQL Server can free and acquire several megabytes of memory each second,
allowing it to quickly adjust to memory allocation changes.&lt;/span&gt;”&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;You
can establish upper and lower limits to the amount of memory (buffer pool) used
by the SQL Server database engine with the&amp;nbsp;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;min server memory&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;max server memory&lt;/b&gt;&amp;nbsp;configuration options.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;“&lt;span style=&quot;background: none repeat scroll 0% 0% white; color: black;&quot;&gt;Note that the&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;max server memory&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;option only limits the size of the SQL
Server buffer pool. The&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;max
server memory&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;option does not
limit a remaining unreserved memory area that SQL Server leaves for allocations
of other components such as extended stored procedures, COM objects, non-shared
DLLs, EXEs, and MAPI components. Because of the preceding allocations, it is
normal for the SQL Server private bytes to exceed the&lt;b&gt;max server memory&lt;/b&gt;&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;configuration.&lt;span class=&quot;apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;”&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;If
you are running 32-bit SQL Server, and need access to more than 2 GB of user
mode VAS (Virtual Address Space), then you&amp;nbsp;&lt;i&gt;have&lt;/i&gt;&amp;nbsp;to use Lock
Pages in Memory; there is no debate there. You must configure the OS to use
Physical Address Extensions (&lt;b&gt;PAE&lt;/b&gt;), enable Address Windowing Extensions (&lt;b&gt;AWE&lt;/b&gt;),
and then assign the&amp;nbsp;&lt;b&gt;Lock Pages in Memory&lt;/b&gt;&amp;nbsp;permission to the SQL
Server account so that it can allocate AWE memory, via calls to&amp;nbsp;&lt;b&gt;AllocateUserPhysicalPages()
(Windows API)&lt;/b&gt;. So, in a typical 32-bit server using LPIM(Lock Pages In
Memory) you&#39;d have, in addition to the 2 GB of pageable user mode VAS, a
separate AWE-mapped area, up to 64 GB (the PAE pointer was 36-bit), of
non-pageable memory. This AWE-mapped area is for exclusive use by the&amp;nbsp;&lt;i&gt;data
cache portion&lt;/i&gt;&amp;nbsp;of the buffer pool. The rest of the buffer pool (mainly
the plan cache), and other non-buffer pool allocations are still mapped within
the 2 GB of user mode VAS.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;However,
the advent of a 64-bit SQL Server process completely changed the dynamics of
memory allocation by the SQLOS. In place of the default 2 GB user mode VAS, for
a 32-bit process, a 64-bit process has access to up to 8 TB of user mode VAS
out-of-the-box, without any need for further configuration changes! 64-bit
users now have a potentially-vast amount of memory for the buffer pool, but all
of which is allocated via&amp;nbsp;&lt;b&gt;VirtualAlloc&lt;/b&gt;, and backed by user mode
VAS, and so is pageable&amp;nbsp;&lt;i&gt;i.e.&lt;/i&gt;&amp;nbsp;in the absence of LPIM, the
memory allocated for the data and plan cache is pageable.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1in; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Since
the operating system still requires memory to operate, you should set the max
server memory configuration option to ensure that the operating system has
sufficient memory once SQL Server has committed its memory for use.&amp;nbsp; This
is especially important on 64 bit servers where the larger VAS allows for the
SQL process to take all of the physical memory which can result in a paging
situation for the SQL processes, degrading performance.&amp;nbsp; For this reason,
64 bit servers should use the Lock Pages in Memory right so that the AWE
Mechanism is used to allocate memory, preventing paging of the BPool.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1in; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1in; text-indent: -0.25in;&quot;&gt;
&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
References:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: .75in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
1.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://www.simple-talk.com/sql/database-administration/great-sql-server-debates-lock-pages-in-memory/&quot;&gt;http://www.simple-talk.com/sql/database-administration/great-sql-server-debates-lock-pages-in-memory/&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: .75in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
2.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/08/24/troubleshooting-the-sql-server-memory-leak-or-understanding-sql-server-memory-usage.aspx&quot;&gt;http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/08/24/troubleshooting-the-sql-server-memory-leak-or-understanding-sql-server-memory-usage.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: .75in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
3.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/ed17f4d1-0980-4e3a-9a12-26a85cbbac04&quot;&gt;http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/ed17f4d1-0980-4e3a-9a12-26a85cbbac04&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: .75in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
4.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://support.microsoft.com/kb/321363&quot;&gt;http://support.microsoft.com/kb/321363&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: .75in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;5.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://blogs.msdn.com/b/slavao/archive/2005/04/29/413425.aspx&quot;&gt;http://blogs.msdn.com/b/slavao/archive/2005/04/29/413425.aspx&lt;/a&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/6570835467205864794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2012/05/memory-behavior-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6570835467205864794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/6570835467205864794'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2012/05/memory-behavior-in-sql-server.html' title='Memory Behavior in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-2393822314377633840</id><published>2012-05-05T22:11:00.000-07:00</published><updated>2019-01-10T01:09:44.629-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="Performance"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="TempDB Configuration"/><title type='text'>TempDB Configuration in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

Recently in our production environment we were facing performance issues. After tracking down we found that reason could be because of incorrect tempDB configuration. So, I started reading few articles on msdn and written by experts about tempDB configuration and came up with below summary.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l2 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;symbol&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% rgb(206 , 213 , 219); color: #333333;&quot;&gt;Should I use
1 file or multiple files for TempDB?&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;One
TempDB data file per physical corefor the SQL Server instance.This prevents
helps contention that can occur during peak tempdb activity.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;The
data files for tempdb should all be the same size. This allows for optimal
proportional-fill performance. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;All
data files have equal growth increment&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;No
data files have percent growth increment&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l2 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;symbol&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% rgb(206 , 213 , 219); color: #333333;&quot;&gt;Where (i.e.
what disks) should I create TempDB?&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Put
the tempdb database on a fast I/O subsystem. Use disk striping if there are
many directly attached disks.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Put
the tempdb database on disks that differ from those that are used by user
databases.Tempdb should be separated and isolated from user databases.&amp;nbsp;
This creates contention between the user databases and tempdb.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Tempdb
data files and log files should be on separate disks.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;The
TempDB files should&amp;nbsp;definitely&amp;nbsp;not be on the system (C) drive. If
TempDB grows out of control, perhaps due to a large sort query, the system can
run out of hard drive space and fail to start.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l2 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;symbol&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;background: none repeat scroll 0% 0% rgb(206 , 213 , 219); color: #333333;&quot;&gt;What should
be the size of TempDB?&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Unlike
user databases where you can probably estimate the growth rate of tables over
time based on the workload, estimating the size of TempDB is non-trivial.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;The
size of TempDB can be affected for example by a change in query plans, version
store when there is a long running transaction and so on.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;The
best way to estimate the size of TempDB is by running your workload in a test
environment. Once you have a good estimate of the size of TempDB, use Alter
Database command to set its size with a safety factor&amp;nbsp;that you feel is
appropriate.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Don’t
rely on auto-grow to manage file sizes. You must set the appropriate size of
TempDB using Alter Database command.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;Auto-grow
causes a pause during processing when you can least afford it&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l3 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Auto-grow
leads to physical fragmentation&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l1 level1 lfo4; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;; font-size: 12pt; line-height: 115%;&quot;&gt;o&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 12pt; line-height: 115%;&quot;&gt;Tempdb
Data files should be large enough to handle the workload for all 24 hours of
the day.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1in; text-indent: -0.25in;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1in; text-indent: -0.25in;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1in; text-indent: -0.25in;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1in; text-indent: -0.25in;&quot;&gt;
&lt;br /&gt;
References:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
1.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://blogs.msdn.com/b/dfurman/archive/2010/04/05/tempdb-configuration-check-script.aspx&quot;&gt;http://blogs.msdn.com/b/dfurman/archive/2010/04/05/tempdb-configuration-check-script.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
2.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://sqlserverpedia.com/blog/sql-server-bloggers/5-common-mistakes-with-tempdb/&quot;&gt;http://sqlserverpedia.com/blog/sql-server-bloggers/5-common-mistakes-with-tempdb/&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
3.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://blogs.msdn.com/b/sqlserverstorageengine/archive/2009/01/04/managing-tempdb-in-sql-server-tempdb-configuration.aspx&quot;&gt;http://blogs.msdn.com/b/sqlserverstorageengine/archive/2009/01/04/managing-tempdb-in-sql-server-tempdb-configuration.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
4.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/cc966545.aspx&quot;&gt;http://technet.microsoft.com/en-us/library/cc966545.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
5.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;a href=&quot;http://sqlserverpedia.com/wiki/Configuring_Database_Files_for_Optimal_Perfomance#TempDB_Database_Configuration&quot;&gt;http://sqlserverpedia.com/wiki/Configuring_Database_Files_for_Optimal_Perfomance#TempDB_Database_Configuration&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/2393822314377633840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2012/05/tempdb-configuration.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2393822314377633840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/2393822314377633840'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2012/05/tempdb-configuration.html' title='TempDB Configuration in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6032850948458789302.post-8065456242187527722</id><published>2012-04-08T19:52:00.000-07:00</published><updated>2019-01-10T01:09:56.406-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DBA"/><category scheme="http://www.blogger.com/atom/ns#" term="t-sql"/><title type='text'>Few articles about different types of locks in SQL Server</title><content type='html'>&lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-111366159-1&quot;&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-111366159-1&#39;);
&lt;/script&gt;

&lt;ul&gt;
&lt;li style=&quot;color: black;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;a href=&quot;http://www.sqlteam.com/article/application-locks-or-mutexes-in-sql-server-2005&quot;&gt;http://www.sqlteam.com/article/application-locks-or-mutexes-in-sql-server-2005&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://akashonly.blogspot.com/feeds/8065456242187527722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://akashonly.blogspot.com/2012/04/few-articles-about-different-types-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/8065456242187527722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6032850948458789302/posts/default/8065456242187527722'/><link rel='alternate' type='text/html' href='http://akashonly.blogspot.com/2012/04/few-articles-about-different-types-of.html' title='Few articles about different types of locks in SQL Server'/><author><name>Akash Agrawal</name><uri>http://www.blogger.com/profile/11231950195599234664</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>