<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/4.0.3" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Data Management - Author(s): George Mastros (gmmastros)</title>
		<link>http://blogs.lessthandot.com/index.php/DataMgmt/</link>
		<atom:link rel="self" type="application/rss+xml" href="http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2" />
		<description></description>
		<language>en-GB</language>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=4.0.3"/>
		<ttl>60</ttl>
				<item>
			<title>Finding Exact Duplicate Indexes</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/finding-exact-duplicate-indexes</link>
			<pubDate>Thu, 12 Apr 2012 17:14:00 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>
<category domain="alt">Microsoft SQL Server Admin</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1700@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;This blog is not meant to be a comprehensive explanation of indexes.  It is meant to help you determine if there are duplicate indexes within your database.  There appears to be some debate regarding what is a duplicate index.  This article defines an &amp;#8220;Exact Duplicate Index&amp;#8221; where there are multiple non-clustered indexes with exactly the same keys and include columns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This query will ignore clustered indexes.&lt;/strong&gt;&lt;br /&gt;
It is possible to create a non-clustered index with keys that match a clustered index.  Sometimes, this could be considered a duplicate index, and sometimes it should not be considered a duplicate.  For example, suppose you have a wide table so that there is only one row per data page.  Also suppose you have a query that only needs to use the key columns.  It will be faster to use a non-clustered index for the query instead of the clustered index because the non-clustered index would only include the key columns, and you will get more columns per data page.  The non-clustered index would require less file I/O, and therefore increased performance.&lt;/p&gt;

&lt;p&gt;If you have a wide table with many rows, a non-clustered index that matches the key columns of the clustered index will improve performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This query will ignore partial duplicates with similar keys.&lt;/strong&gt;&lt;br /&gt;
It is possible to create indexes with similar keys, and sometimes it is beneficial to do so.  For example, suppose you had an index with key columns (Col1, Col2) and another with (Col1, Col2, Col3).  You probably don&amp;#8217;t need the first index because the second index will suffice.  However, there are cases where Col3 could be wide and using it would cause extra I/O compared to the first index.  It is probably rare that you would see any difference in performance between these indexes.  I will be writing another article that explains this in depth and provides a query that will return these possible duplicates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This query will ignore partial duplicates with the same keys and similar includes.&lt;/strong&gt;&lt;br /&gt;
Column ordering for include columns does not matter, but which columns are included can make a big difference in the performance of a query.  There could be similar indexes that have the same key columns but different include columns.  This can affect the size of the index and cause more I/O.  There will be another blog that explains this in depth and provides a query to identify duplicate indexes with similar includes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The query to identify exact duplicates:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb72635&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;; &lt;span style=&quot;color: #0000FF;&quot;&gt;With&lt;/span&gt; IndexColumns &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;select&lt;/span&gt;&amp;nbsp; I.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;SubString&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&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: #0000FF;&quot;&gt;select&lt;/span&gt;&amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;,&#039;&lt;/span&gt; + &lt;span style=&quot;color: #FF00FF;&quot;&gt;Convert&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;VarChar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, Column_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&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: #0000FF;&quot;&gt;from&lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;index_columns&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; k&lt;br /&gt;&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: #0000FF;&quot;&gt;where&lt;/span&gt;&amp;nbsp; &amp;nbsp;k.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt; = i.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;br /&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; and k.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt; = i.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt;&lt;br /&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; and is_included_column = &lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&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: #0000FF;&quot;&gt;Order&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;By&lt;/span&gt; key_ordinal&lt;br /&gt;&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: #0000FF;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;xml&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; KeyColumns,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;SubString&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;Coalesce&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&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: #0000FF;&quot;&gt;select&lt;/span&gt;&amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;,&#039;&lt;/span&gt; + &lt;span style=&quot;color: #FF00FF;&quot;&gt;Convert&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;VarChar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, Column_id&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&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: #0000FF;&quot;&gt;from&lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;index_columns&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;as&lt;/span&gt; k&lt;br /&gt;&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: #0000FF;&quot;&gt;where&lt;/span&gt;&amp;nbsp; &amp;nbsp;k.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt; = i.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;br /&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; and k.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt; = i.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt;&lt;br /&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; and is_included_column = &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;br /&gt;&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: #0000FF;&quot;&gt;Order&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;By&lt;/span&gt; column_id&lt;br /&gt;&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: #0000FF;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;xml&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; IncludeColumns&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;indexes&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; I&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Inner&lt;/span&gt; Join &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;Tables&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; T&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;On&lt;/span&gt; I.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt; = T.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Where&lt;/span&gt;&amp;nbsp; &amp;nbsp;I.&lt;span style=&quot;color: #202020;&quot;&gt;type_desc&lt;/span&gt; &amp;lt;&amp;gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Clustered&#039;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And T.&lt;span style=&quot;color: #202020;&quot;&gt;is_ms_shipped&lt;/span&gt; = &lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; &amp;nbsp;&lt;span style=&quot;color: #FF00FF;&quot;&gt;Object_Name&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;AIndex.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; TableName,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AIndex.&lt;span style=&quot;color: #202020;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; Index1,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bIndex.&lt;span style=&quot;color: #202020;&quot;&gt;Name&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; Index2,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Drop Index [&#039;&lt;/span&gt; + bIndex.&lt;span style=&quot;color: #202020;&quot;&gt;Name&lt;/span&gt; + &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;] On [&#039;&lt;/span&gt; + &lt;span style=&quot;color: #FF00FF;&quot;&gt;Object_Name&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;AIndex.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; + &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;]&#039;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; DropCode&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt;&amp;nbsp; &amp;nbsp; IndexColumns &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; A&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Inner&lt;/span&gt; Join IndexColumns &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; B&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;On&lt;/span&gt; A.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt; = B.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And A.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt; &amp;lt; B.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And A.&lt;span style=&quot;color: #202020;&quot;&gt;KeyColumns&lt;/span&gt; = B.&lt;span style=&quot;color: #202020;&quot;&gt;KeyColumns&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And A.&lt;span style=&quot;color: #202020;&quot;&gt;IncludeColumns&lt;/span&gt; = B.&lt;span style=&quot;color: #202020;&quot;&gt;IncludeColumns&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Inner&lt;/span&gt; Join &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;indexes&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; AIndex&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;On&lt;/span&gt; A.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt; = AIndex.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And A.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt; = AIndex.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Inner&lt;/span&gt; Join &lt;span style=&quot;color: #00AF00;&quot;&gt;sys&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;indexes&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; BIndex&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;On&lt;/span&gt; B.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt; = BIndex.&lt;span style=&quot;color: #FF00FF;&quot;&gt;object_id&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And B.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt; = BIndex.&lt;span style=&quot;color: #202020;&quot;&gt;index_id&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb94209&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When you run this query, you will see two columns in the output showing you the duplicates.  Since these are exact duplicates, you can drop one of them.  Which one you drop is up to you.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/finding-exact-duplicate-indexes&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>This blog is not meant to be a comprehensive explanation of indexes.  It is meant to help you determine if there are duplicate indexes within your database.  There appears to be some debate regarding what is a duplicate index.  This article defines an &#8220;Exact Duplicate Index&#8221; where there are multiple non-clustered indexes with exactly the same keys and include columns.</p>

<p><strong>This query will ignore clustered indexes.</strong><br />
It is possible to create a non-clustered index with keys that match a clustered index.  Sometimes, this could be considered a duplicate index, and sometimes it should not be considered a duplicate.  For example, suppose you have a wide table so that there is only one row per data page.  Also suppose you have a query that only needs to use the key columns.  It will be faster to use a non-clustered index for the query instead of the clustered index because the non-clustered index would only include the key columns, and you will get more columns per data page.  The non-clustered index would require less file I/O, and therefore increased performance.</p>

<p>If you have a wide table with many rows, a non-clustered index that matches the key columns of the clustered index will improve performance.</p>

<p><strong>This query will ignore partial duplicates with similar keys.</strong><br />
It is possible to create indexes with similar keys, and sometimes it is beneficial to do so.  For example, suppose you had an index with key columns (Col1, Col2) and another with (Col1, Col2, Col3).  You probably don&#8217;t need the first index because the second index will suffice.  However, there are cases where Col3 could be wide and using it would cause extra I/O compared to the first index.  It is probably rare that you would see any difference in performance between these indexes.  I will be writing another article that explains this in depth and provides a query that will return these possible duplicates.</p>

<p><strong>This query will ignore partial duplicates with the same keys and similar includes.</strong><br />
Column ordering for include columns does not matter, but which columns are included can make a big difference in the performance of a query.  There could be similar indexes that have the same key columns but different include columns.  This can affect the size of the index and cause more I/O.  There will be another blog that explains this in depth and provides a query to identify duplicate indexes with similar includes.</p>

<p><strong>The query to identify exact duplicates:</strong></p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb63473'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb63473','cb91064'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb63473" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">; <span style="color: #0000FF;">With</span> IndexColumns <span style="color: #0000FF;">As</span></li><li style="" class="li2"><span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">select</span>&nbsp; I.<span style="color: #FF00FF;">object_id</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I.<span style="color: #202020;">index_id</span>,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF00FF;">SubString</span><span style="color: #808080;">&#40;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">select</span>&nbsp; <span style="color: #FF0000;">','</span> + <span style="color: #FF00FF;">Convert</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">VarChar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span>, Column_id<span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">from</span>&nbsp; &nbsp; <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">index_columns</span> <span style="color: #0000FF;">as</span> k</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">where</span>&nbsp; &nbsp;k.<span style="color: #FF00FF;">object_id</span> = i.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and k.<span style="color: #202020;">index_id</span> = i.<span style="color: #202020;">index_id</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and is_included_column = <span style="color: #000;">0</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Order</span> <span style="color: #0000FF;">By</span> key_ordinal</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">for</span> <span style="color: #0000FF;">xml</span> <span style="color: #0000FF;">path</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#41;</span>, <span style="color: #000;">2</span>, <span style="color: #000;">1000</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">As</span> KeyColumns,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF00FF;">SubString</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">Coalesce</span><span style="color: #808080;">&#40;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#40;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">select</span>&nbsp; <span style="color: #FF0000;">','</span> + <span style="color: #FF00FF;">Convert</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">VarChar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">10</span><span style="color: #808080;">&#41;</span>, Column_id<span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">from</span>&nbsp; &nbsp; <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">index_columns</span> <span style="color: #0000FF;">as</span> k</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">where</span>&nbsp; &nbsp;k.<span style="color: #FF00FF;">object_id</span> = i.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and k.<span style="color: #202020;">index_id</span> = i.<span style="color: #202020;">index_id</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and is_included_column = <span style="color: #000;">1</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Order</span> <span style="color: #0000FF;">By</span> column_id</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">for</span> <span style="color: #0000FF;">xml</span> <span style="color: #0000FF;">path</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">&#41;</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span>, <span style="color: #000;">2</span>, <span style="color: #000;">1000</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">As</span> IncludeColumns</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">From</span>&nbsp; &nbsp; <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">indexes</span> <span style="color: #0000FF;">As</span> I</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Inner</span> Join <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">Tables</span> <span style="color: #0000FF;">As</span> T</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">On</span> I.<span style="color: #FF00FF;">object_id</span> = T.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #0000FF;">Where</span>&nbsp; &nbsp;I.<span style="color: #202020;">type_desc</span> &lt;&gt; <span style="color: #FF0000;">'Clustered'</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And T.<span style="color: #202020;">is_ms_shipped</span> = <span style="color: #000;">0</span></li><li style="" class="li2"><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Select</span> &nbsp;<span style="color: #FF00FF;">Object_Name</span><span style="color: #808080;">&#40;</span>AIndex.<span style="color: #FF00FF;">object_id</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">As</span> TableName,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; AIndex.<span style="color: #202020;">name</span> <span style="color: #0000FF;">As</span> Index1,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; bIndex.<span style="color: #202020;">Name</span> <span style="color: #0000FF;">As</span> Index2,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">'Drop Index ['</span> + bIndex.<span style="color: #202020;">Name</span> + <span style="color: #FF0000;">'] On ['</span> + <span style="color: #FF00FF;">Object_Name</span><span style="color: #808080;">&#40;</span>AIndex.<span style="color: #FF00FF;">object_id</span><span style="color: #808080;">&#41;</span> + <span style="color: #FF0000;">']'</span> <span style="color: #0000FF;">As</span> DropCode</li><li style="" class="li1"><span style="color: #0000FF;">From</span>&nbsp; &nbsp; IndexColumns <span style="color: #0000FF;">As</span> A</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Inner</span> Join IndexColumns &nbsp;<span style="color: #0000FF;">As</span> B</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">On</span> A.<span style="color: #FF00FF;">object_id</span> = B.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And A.<span style="color: #202020;">index_id</span> &lt; B.<span style="color: #202020;">index_id</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And A.<span style="color: #202020;">KeyColumns</span> = B.<span style="color: #202020;">KeyColumns</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And A.<span style="color: #202020;">IncludeColumns</span> = B.<span style="color: #202020;">IncludeColumns</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Inner</span> Join <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">indexes</span> <span style="color: #0000FF;">As</span> AIndex</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">On</span> A.<span style="color: #FF00FF;">object_id</span> = AIndex.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And A.<span style="color: #202020;">index_id</span> = AIndex.<span style="color: #202020;">index_id</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Inner</span> Join <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">indexes</span> <span style="color: #0000FF;">As</span> BIndex</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">On</span> B.<span style="color: #FF00FF;">object_id</span> = BIndex.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And B.<span style="color: #202020;">index_id</span> = BIndex.<span style="color: #202020;">index_id</span></li></ol></div><div id="cb91064" style="display: none; color: red;"></div></div></div>

<p>When you run this query, you will see two columns in the output showing you the duplicates.  Since these are exact duplicates, you can drop one of them.  Which one you drop is up to you.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/finding-exact-duplicate-indexes">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/finding-exact-duplicate-indexes#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1700</wfw:commentRss>
		</item>
				<item>
			<title>Do not use reserved keywords for your column names</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/do-not-use-reserved-keywords</link>
			<pubDate>Mon, 19 Mar 2012 16:16:00 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>			<guid isPermaLink="false">1670@http://blogs.lessthandot.com/</guid>
						<description>&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/do-not-use-reserved-keywords&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Column names and table names should not use reserved keywords in your database. You can use reserved keywords because SQL Server will allow it.  However, this should not be done because it makes writing and reading queries more difficult. When you use a reserved keyword for a column or table name, you need to use [square brackets] around the name.</p>

<p>The following query compares your column names against a list of <a href="http://msdn.microsoft.com/en-us/library/aa238507(v=sql.80).aspx">identified keywords</a>. Some of the keywords are SQL Server reserved words, some are ODBC reserved words, and the rest are future reserved words.</p>

<p><strong>How to detect this problem:</strong></p>
<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb86351'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb86351','cb78997'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb86351" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Declare</span> @Temp <span style="color: #0000FF;">Table</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">Data</span> <span style="color: #0000FF;">VarChar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">50</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ABSOLUTE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ACTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ADA'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ADD'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ADMIN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'AFTER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'AGGREGATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ALIAS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ALL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ALLOCATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ALTER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'AND'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ANY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ARE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ARRAY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'AS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ASC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ASSERTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'AT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'AUTHORIZATION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'AVG'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BACKUP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BEFORE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BEGIN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BETWEEN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BINARY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BIT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BIT_LENGTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BLOB'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BOOLEAN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BOTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BREADTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BREAK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BROWSE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BULK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'BY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CALL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CASCADE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CASCADED'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CASE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CAST'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CATALOG'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CHAR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CHAR_LENGTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CHARACTER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CHARACTER_LENGTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CHECK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CHECKPOINT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CLASS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CLOB'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CLOSE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CLUSTERED'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COALESCE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COLLATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COLLATION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COLUMN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COMMIT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COMPLETION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COMPUTE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONNECT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONNECTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONSTRAINT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONSTRAINTS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONSTRUCTOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONTAINS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONTAINSTABLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONTINUE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CONVERT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CORRESPONDING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'COUNT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CREATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CROSS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CUBE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURRENT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURRENT_DATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURRENT_PATH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURRENT_ROLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURRENT_TIME'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURRENT_TIMESTAMP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURRENT_USER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CURSOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'CYCLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DATA'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DATABASE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DAY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DBCC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DEALLOCATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DEC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DECIMAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DECLARE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DEFAULT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DEFERRABLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DEFERRED'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DELETE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DENY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DEPTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DEREF'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DESC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DESCRIBE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DESCRIPTOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DESTROY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DESTRUCTOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DETERMINISTIC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DIAGNOSTICS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DICTIONARY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DISCONNECT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DISK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DISTINCT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DISTRIBUTED'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DOMAIN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DOUBLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DROP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DUMMY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DUMP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'DYNAMIC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EACH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ELSE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'END'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'END-EXEC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EQUALS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ERRLVL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ESCAPE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EVERY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXCEPT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXCEPTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXEC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXECUTE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXISTS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXIT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXTERNAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'EXTRACT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FALSE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FETCH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FILE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FILLFACTOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FIRST'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FLOAT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FOREIGN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FORTRAN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FOUND'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FREE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FREETEXT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FREETEXTTABLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FROM'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FULL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'FUNCTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GENERAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GET'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GLOBAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GO'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GOTO'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GRANT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GROUP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'GROUPING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'HAVING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'HOLDLOCK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'HOST'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'HOUR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IDENTITY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IDENTITY_INSERT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IDENTITYCOL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IF'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IGNORE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IMMEDIATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INCLUDE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INDEX'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INDICATOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INITIALIZE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INITIALLY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INNER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INOUT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INPUT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INSENSITIVE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INSERT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INTEGER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INTERSECT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INTERVAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'INTO'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'IS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ISOLATION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ITERATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'JOIN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'KEY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'KILL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LANGUAGE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LARGE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LAST'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LATERAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LEADING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LEFT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LESS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LEVEL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LIKE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LIMIT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LINENO'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LOAD'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LOCAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LOCALTIME'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LOCALTIMESTAMP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LOCATOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'LOWER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MAP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MATCH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MAX'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MIN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MINUTE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MODIFIES'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MODIFY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MODULE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'MONTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NAMES'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NATIONAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NATURAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NCHAR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NCLOB'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NEW'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NEXT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NO'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NOCHECK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NONCLUSTERED'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NONE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NOT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NULL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NULLIF'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'NUMERIC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OBJECT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OCTET_LENGTH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OF'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OFF'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OFFSETS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OLD'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ON'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ONLY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OPEN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OPENDATASOURCE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OPENQUERY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OPENROWSET'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OPENXML'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OPERATION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OPTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ORDER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ORDINALITY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OUT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OUTER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OUTPUT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OVER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'OVERLAPS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PAD'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PARAMETER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PARAMETERS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PARTIAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PASCAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PATH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PERCENT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PLAN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'POSITION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'POSTFIX'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PRECISION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PREFIX'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PREORDER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PREPARE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PRESERVE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PRIMARY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PRINT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PRIOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PRIVILEGES'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PROC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PROCEDURE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'PUBLIC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RAISERROR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'READ'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'READS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'READTEXT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'REAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RECONFIGURE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RECURSIVE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'REF'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'REFERENCES'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'REFERENCING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RELATIVE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'REPLICATION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RESTORE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RESTRICT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RESULT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RETURN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RETURNS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'REVOKE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RIGHT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROLLBACK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROLLUP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROUTINE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROW'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROWCOUNT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROWGUIDCOL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ROWS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'RULE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SAVE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SAVEPOINT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SCHEMA'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SCOPE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SCROLL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SEARCH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SECOND'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SECTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SELECT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SEQUENCE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SESSION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SESSION_USER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SET'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SETS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SETUSER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SHUTDOWN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SIZE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SMALLINT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SOME'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SPACE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SPECIFIC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SPECIFICTYPE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SQL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SQLCA'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SQLCODE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SQLERROR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SQLEXCEPTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SQLSTATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SQLWARNING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'START'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'STATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'STATEMENT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'STATIC'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'STATISTICS'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'STRUCTURE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SUBSTRING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SUM'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'SYSTEM_USER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TABLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TEMPORARY'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TERMINATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TEXTSIZE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'THAN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'THEN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TIME'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TIMESTAMP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TIMEZONE_HOUR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TIMEZONE_MINUTE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TO'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TOP'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRAILING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRAN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRANSACTION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRANSLATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRANSLATION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TREAT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRIGGER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRIM'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRUE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TRUNCATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'TSEQUAL'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UNDER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UNION'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UNIQUE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UNKNOWN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UNNEST'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UPDATE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UPDATETEXT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'UPPER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'USAGE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'USE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'USER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'USING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'VALUE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'VALUES'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'VARCHAR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'VARIABLE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'VARYING'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'VIEW'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WAITFOR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WHEN'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WHENEVER'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WHERE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WHILE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WITH'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WITHOUT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WORK'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WRITE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'WRITETEXT'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'YEAR'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> @Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'ZONE'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Select</span>&nbsp; <span style="color: #FF00FF;">object_name</span><span style="color: #808080;">&#40;</span>C.<span style="color: #FF00FF;">object_id</span><span style="color: #808080;">&#41;</span>, C.<span style="color: #202020;">Name</span></li><li style="" class="li1"><span style="color: #0000FF;">From</span>&nbsp; &nbsp; <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">columns</span> <span style="color: #0000FF;">As</span> C</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Inner</span> Join <span style="color: #00AF00;">sys</span>.<span style="color: #00AF00;">objects</span> <span style="color: #0000FF;">As</span> O</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">On</span> C.<span style="color: #FF00FF;">object_id</span> = O.<span style="color: #FF00FF;">object_id</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">Inner</span> Join @Temp T</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">On</span> C.<span style="color: #202020;">Name</span> = <span style="color: #0000FF;">Data</span></li><li style="" class="li2"><span style="color: #0000FF;">Where</span>&nbsp; &nbsp;is_ms_shipped = <span style="color: #000;">0</span></li><li style="" class="li1"><span style="color: #0000FF;">Order</span> <span style="color: #0000FF;">By</span> <span style="color: #FF00FF;">object_name</span><span style="color: #808080;">&#40;</span>C.<span style="color: #FF00FF;">object_id</span><span style="color: #808080;">&#41;</span>, C.<span style="color: #202020;">Name</span></li></ol></div><div id="cb78997" style="display: none; color: red;"></div></div></div>

<p><strong>How to correct it:</strong><br />
Correcting for this type of problem can be challenging because you cannot just willy nilly go around changing column names.  You are likely to have code that uses the column with the original name and this code will need to change to accommodate the changed column name.  To make matters more difficult, you could have systems outside of the database that are sending dynamic SQL making it more difficult to find all of the occurrences in code.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/do-not-use-reserved-keywords">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/do-not-use-reserved-keywords#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1670</wfw:commentRss>
		</item>
				<item>
			<title>SQLCop integration with Red Gate's SQL Test</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sqlcop-integration-with-red-gate</link>
			<pubDate>Wed, 04 Jan 2012 18:52:00 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>
<category domain="alt">Database Programming</category>
<category domain="alt">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1580@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Approximately a year and a half ago, friends of mine and I created SQLCop.  Our motivation was to provide a tool that users can download and run against their database.  This tool is very effective at detecting common problems with database configurations and TSQL code.  Not every issue highlighted by SQLCop requires a fix, but you are very likely to discover potential problems that you didn&#039;t even know you had.&lt;/p&gt;

&lt;p&gt;About a year ago, I met Dennis Lloyd, Jr. and Sebastian Meine at a presentation they were giving for tSQLt (&lt;a href=&quot;http://tSQLt.org&quot;&gt;a unit testing framework for SQL Server&lt;/a&gt;) that they were working on.  I was intrigued because I had always wanted to write unit tests for my tSQL code but hadn&amp;#8217;t been able to implement anything because of time constraints on my end.  The tSQLt framework allowed me to forget about the mechanics of implementing and running the tests and allowed me to focus on writing the tests.&lt;/p&gt;

&lt;p&gt;Several weeks ago, I was approached by Justin Caldicott at Red Gate Software.  He informed that they had recently released SQL Test which is a SSMS add-in that makes writing and executing tSQLt tests easier.  &lt;/p&gt;

&lt;p&gt;Justin was interested in including SQLCop tests within SQL Test.  I downloaded and installed SQLTest.  I was surprised to see that it recognized all of the tests that I had written manually.  I also like how easy it is to run tests and create new ones.  This tool has already saved me time.&lt;/p&gt;

&lt;p&gt;I spent a relatively short amount of time re-writing a couple of the SQLCop tests to run within the tSQLt framework.  At this point, there are several tests already written and included with SQL Test (Preview 2).  &lt;/p&gt;

&lt;p&gt;If you haven&#039;t done so already, I encourage you to download and install &lt;a href=&quot;http://sqlcop.lessthandot.com&quot;&gt;SQLCop&lt;/a&gt;.  I would be extremely surprised if you didn&amp;#8217;t find something useful with it.&lt;/p&gt;

&lt;p&gt;I also encourage everyone to download and install &lt;a href=&quot;http://www.red-gate.com/products/sql-development/sql-test/&quot;&gt;SQL Test&lt;/a&gt; so that you can see for yourself how easy it is to run unit tests on your database.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sqlcop-integration-with-red-gate&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Approximately a year and a half ago, friends of mine and I created SQLCop.  Our motivation was to provide a tool that users can download and run against their database.  This tool is very effective at detecting common problems with database configurations and TSQL code.  Not every issue highlighted by SQLCop requires a fix, but you are very likely to discover potential problems that you didn't even know you had.</p>

<p>About a year ago, I met Dennis Lloyd, Jr. and Sebastian Meine at a presentation they were giving for tSQLt (<a href="http://tSQLt.org">a unit testing framework for SQL Server</a>) that they were working on.  I was intrigued because I had always wanted to write unit tests for my tSQL code but hadn&#8217;t been able to implement anything because of time constraints on my end.  The tSQLt framework allowed me to forget about the mechanics of implementing and running the tests and allowed me to focus on writing the tests.</p>

<p>Several weeks ago, I was approached by Justin Caldicott at Red Gate Software.  He informed that they had recently released SQL Test which is a SSMS add-in that makes writing and executing tSQLt tests easier.  </p>

<p>Justin was interested in including SQLCop tests within SQL Test.  I downloaded and installed SQLTest.  I was surprised to see that it recognized all of the tests that I had written manually.  I also like how easy it is to run tests and create new ones.  This tool has already saved me time.</p>

<p>I spent a relatively short amount of time re-writing a couple of the SQLCop tests to run within the tSQLt framework.  At this point, there are several tests already written and included with SQL Test (Preview 2).  </p>

<p>If you haven't done so already, I encourage you to download and install <a href="http://sqlcop.lessthandot.com">SQLCop</a>.  I would be extremely surprised if you didn&#8217;t find something useful with it.</p>

<p>I also encourage everyone to download and install <a href="http://www.red-gate.com/products/sql-development/sql-test/">SQL Test</a> so that you can see for yourself how easy it is to run unit tests on your database.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sqlcop-integration-with-red-gate">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sqlcop-integration-with-red-gate#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1580</wfw:commentRss>
		</item>
				<item>
			<title>Zero-One-Some Testing</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/zero-one-some-testing</link>
			<pubDate>Tue, 13 Dec 2011 11:33:00 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="alt">Data Modelling &amp; Design</category>
<category domain="main">Database Programming</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1540@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;&lt;em&gt;I met Denis and Sebastian over a year ago when I attended their session on test driven database development.  Since then, I have been using tSQLt to add unit tests to my database.  The following post was written by Denis Lloyd Jr.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;About the Series&lt;/h2&gt;
&lt;p&gt;Test case heuristics are patterns used to help decide the next test to write and ensure test coverage of requirements. This is the second post on a series of test case heuristics pertaining to database testing.&lt;/p&gt;

&lt;p&gt;I&#039;m trying out a new way of delivering series to a wider audience - post sharing! The series home is at: &lt;a href=&quot;http://testdrivendatabases.com/test-heuristics&quot;&gt;http://testdrivendatabases.com/test-heuristics&lt;/a&gt; where you can find links to all articles in the series. The posts will be scattered over a variety of websites and blogs.&lt;/p&gt;

&lt;h2&gt;Definition:&lt;/h2&gt;
&lt;p&gt;Zero-One-Some says that if multiple instances of a value are allowed, then there should be a test for zero of them; one of them; and some of them. Zero-One-Some is sometimes referred to as Zero-One-Many and is often related to cardinality in the database.&lt;/p&gt;

&lt;p&gt;For example, a view may return multiple records. When testing the view, a test should be written where we expect zero records returned; another test for exactly one record returned; and another test for several rows returned.&lt;/p&gt;
&lt;div class=&quot;image_block&quot;&gt;&lt;a href=&quot;/media/blogs/DataMgmt/ZeroOneZomeTesting.png?mtime=1323782210&quot;&gt;&lt;img src=&quot;/media/blogs/DataMgmt/ZeroOneZomeTesting.png?mtime=1323782210&quot; alt=&quot;&quot; width=&quot;898&quot; height=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;Zero-One-Some may be considered both on the input (e.g. a loop that may process multiple values) or the output (e.g. a query that returns multiple rows).&lt;/p&gt;

&lt;h2&gt;Purpose:&lt;/h2&gt;
&lt;p&gt;Zero-One-Some testing helps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Focus on correct behavior when there are multiple inputs or outputs&lt;/li&gt;
&lt;li&gt;Clarify the requirements when zero records should be processed; a common source of database defects.&lt;/li&gt;
&lt;li&gt;Prevent mistakes when using grouping in queries&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Example:&lt;/h2&gt;
&lt;p&gt;The business would like a report of the number of orders and the total revenue from those orders for each of the last 3 months. The report may look like this:&lt;/p&gt;
&lt;pre&gt;Month             Number of Orders              Revenue from Orders
Nov 2011          52                            $3582.00
Oct 2011          70                            $12399.50
Sep 2011          30                            $899.55&lt;/pre&gt;

&lt;p&gt;It is clear from this requirement that multiple orders must be processed. By applying zero-one-some, we are forced to ask the following questions:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;If there are no orders in the past 3 months, what should the report display? Should it list each month with 0 orders and $0?&lt;/li&gt;
&lt;li&gt;If there are no orders for any particular month, should that month still be listed in the report?&lt;/li&gt;
&lt;li&gt;Aggregations are always interesting spots to test. If there is a null value for an order amount, how should that be treated in the sum? If it&amp;#8217;s not included in the revenue, should it also not be included in the count?&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;

&lt;h2&gt;Notes:&lt;/h2&gt;
&lt;p&gt;Tests for zero records seem to uncover missing requirements or defects in code involving aggregations or in places where programmers assume that there will simply be data (perhaps because their test database already has data in it).&lt;/p&gt;

&lt;p&gt;Whereas tests for one and some records seem to uncover more problems in loops when a specific exit condition is needed.&lt;/p&gt;

&lt;p&gt;Tests for multiple (&quot;some&quot;) records may also be useful when data can be duplicated. Often we assume that data being processed is unique, but asking the question, &quot;what if there are multiple instances of the same record?&quot; can be illuminating.&lt;/p&gt;

&lt;h2&gt;Special Cases:&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Joins&lt;/strong&gt;: When multiple tables are joined together in a query, we must often consider the cardinality of the relationship between the tables. Is there a one-to-one relationship between the tables (and is that relationship enforced)? How about a one-to-many or a many-to-many relationship? These impact what tests are needed.&lt;/p&gt;

&lt;p&gt;The join type (e.g. inner, left or right outer, full) must also be considered. These are a few of the possibilities:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A record exists in the left table, but there are no matches in the right table.&lt;/li&gt;
  &lt;li&gt;A record exists in the left table and there is exactly one match in the right table.&lt;/li&gt;
  &lt;li&gt;A record exists in the left table and has multiple matches in the right table.&lt;/li&gt;
  &lt;li&gt;A record exists in the right table, but has no matches in the left table.&lt;/li&gt;
  &lt;li&gt;And so on...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Filters&lt;/strong&gt;: Zero-one-some is also particularly useful in filters, such as WHERE clauses. Consider the following sub-query, for example:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb40693&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; Name &amp;nbsp; &lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; OrderMgmt.&lt;span style=&quot;color: #202020;&quot;&gt;Customer&lt;/span&gt; &amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; CustomerId = &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; CustomerId &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; OrderMgmt.&lt;span style=&quot;color: #0000FF;&quot;&gt;Order&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; OrderId = @OrderId&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb31397&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;While this is a simplistic case, the programmer is likely expecting exactly one record to be returned from the sub-query. If the sub-query returns zero or multiple records though, the actual behavior of this query may not be so pleasant.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/zero-one-some-testing&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p><em>I met Denis and Sebastian over a year ago when I attended their session on test driven database development.  Since then, I have been using tSQLt to add unit tests to my database.  The following post was written by Denis Lloyd Jr.</em></p>

<h2>About the Series</h2>
<p>Test case heuristics are patterns used to help decide the next test to write and ensure test coverage of requirements. This is the second post on a series of test case heuristics pertaining to database testing.</p>

<p>I'm trying out a new way of delivering series to a wider audience - post sharing! The series home is at: <a href="http://testdrivendatabases.com/test-heuristics">http://testdrivendatabases.com/test-heuristics</a> where you can find links to all articles in the series. The posts will be scattered over a variety of websites and blogs.</p>

<h2>Definition:</h2>
<p>Zero-One-Some says that if multiple instances of a value are allowed, then there should be a test for zero of them; one of them; and some of them. Zero-One-Some is sometimes referred to as Zero-One-Many and is often related to cardinality in the database.</p>

<p>For example, a view may return multiple records. When testing the view, a test should be written where we expect zero records returned; another test for exactly one record returned; and another test for several rows returned.</p>
<div class="image_block"><a href="http://blogs.lessthandot.com/media/blogs/DataMgmt/ZeroOneZomeTesting.png?mtime=1323782210"><img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/ZeroOneZomeTesting.png?mtime=1323782210" alt="" width="898" height="240" /></a></div>

<p>Zero-One-Some may be considered both on the input (e.g. a loop that may process multiple values) or the output (e.g. a query that returns multiple rows).</p>

<h2>Purpose:</h2>
<p>Zero-One-Some testing helps:</p>
<ul>
<li>Focus on correct behavior when there are multiple inputs or outputs</li>
<li>Clarify the requirements when zero records should be processed; a common source of database defects.</li>
<li>Prevent mistakes when using grouping in queries</li>
</ul>

<h2>Example:</h2>
<p>The business would like a report of the number of orders and the total revenue from those orders for each of the last 3 months. The report may look like this:</p>
<pre>Month             Number of Orders              Revenue from Orders
Nov 2011          52                            $3582.00
Oct 2011          70                            $12399.50
Sep 2011          30                            $899.55</pre>

<p>It is clear from this requirement that multiple orders must be processed. By applying zero-one-some, we are forced to ask the following questions:<br />
<ul>
<li>If there are no orders in the past 3 months, what should the report display? Should it list each month with 0 orders and $0?</li>
<li>If there are no orders for any particular month, should that month still be listed in the report?</li>
<li>Aggregations are always interesting spots to test. If there is a null value for an order amount, how should that be treated in the sum? If it&#8217;s not included in the revenue, should it also not be included in the count?</li></ul></p>

<h2>Notes:</h2>
<p>Tests for zero records seem to uncover missing requirements or defects in code involving aggregations or in places where programmers assume that there will simply be data (perhaps because their test database already has data in it).</p>

<p>Whereas tests for one and some records seem to uncover more problems in loops when a specific exit condition is needed.</p>

<p>Tests for multiple ("some") records may also be useful when data can be duplicated. Often we assume that data being processed is unique, but asking the question, "what if there are multiple instances of the same record?" can be illuminating.</p>

<h2>Special Cases:</h2>
<p><strong>Joins</strong>: When multiple tables are joined together in a query, we must often consider the cardinality of the relationship between the tables. Is there a one-to-one relationship between the tables (and is that relationship enforced)? How about a one-to-many or a many-to-many relationship? These impact what tests are needed.</p>

<p>The join type (e.g. inner, left or right outer, full) must also be considered. These are a few of the possibilities:</p>

<ul>
  <li>A record exists in the left table, but there are no matches in the right table.</li>
  <li>A record exists in the left table and there is exactly one match in the right table.</li>
  <li>A record exists in the left table and has multiple matches in the right table.</li>
  <li>A record exists in the right table, but has no matches in the left table.</li>
  <li>And so on...</li>
</ul>

<p><strong>Filters</strong>: Zero-one-some is also particularly useful in filters, such as WHERE clauses. Consider the following sub-query, for example:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb73014'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb73014','cb93863'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb73014" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">SELECT</span> Name &nbsp; </li><li style="" class="li2"><span style="color: #0000FF;">FROM</span> OrderMgmt.<span style="color: #202020;">Customer</span> &nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">WHERE</span> CustomerId = &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">SELECT</span> CustomerId &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000FF;">FROM</span> OrderMgmt.<span style="color: #0000FF;">Order</span> &nbsp; &nbsp; &nbsp; &nbsp; </li><li style="" class="li2">&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHERE</span> OrderId = @OrderId<span style="color: #808080;">&#41;</span></li></ol></div><div id="cb93863" style="display: none; color: red;"></div></div></div>

<p>While this is a simplistic case, the programmer is likely expecting exactly one record to be returned from the sub-query. If the sub-query returns zero or multiple records though, the actual behavior of this query may not be so pleasant.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/zero-one-some-testing">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/zero-one-some-testing#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1540</wfw:commentRss>
		</item>
				<item>
			<title>tSQLt Unit Testing</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/tsqlt-unit-testing</link>
			<pubDate>Wed, 20 Jul 2011 15:25:00 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>
<category domain="alt">Database Programming</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1344@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Yesterday, I attended a training class at Microsoft&amp;#8217;s facility in Malvern, Pennsylvania.  This training class was led by Sebastian Meine (&lt;a href=&quot;http://sqlity.net&quot;&gt;sqlity.net&lt;/a&gt;) and Dennis Lloyd (&lt;a href=&quot;http://curiouslycorrect.com&quot;&gt;curiouslycorrect.com&lt;/a&gt;). &lt;/p&gt;

&lt;p&gt;The class was from 9:00 am to 5:00 pm with a short break for lunch.  During the class, Dennis and Sebastian explained how to use tSQLt (&lt;a href=&quot;http://tSQLt.org&quot;&gt;http://tSQLt.org&lt;/a&gt;) to write unit tests for your database code.  tSQLt is a frame work that can be freely downloaded and applied to your database, allowing you to quickly and easily write unit tests.  After learning about the framework and working through the exercises during the class, it is immediately obvious to me how this framework and the techniques explained during the class will benefit my organization.&lt;/p&gt;

&lt;p&gt;Specifically, writing unit tests for the database will allow me to re-factor the code in a safe way, making sure that the code doesn&amp;#8217;t break because I can easily run all of the unit tests for the database, or just the unit tests associated with the code I am in the process of changing.&lt;/p&gt;

&lt;p&gt;Since I already have dozens of views, hundreds of functions and thousands of stored procedures, I cannot take the time to write all the unit tests required for the existing stuff, but I will create unit tests for the new code I write and also unit tests for any bug fixes with the existing code.  Over time I will have a set of unit tests for my database code that will undoubtedly allow me to spend less time fixing defects and more time writing new functionality.&lt;br /&gt;
With my application, most of the bugs discovered by the end user are data related. The tSQLt unit testing framework will allow me to write tests for those bugs and then have confidence that the bug will not return (in the released version of the software).&lt;/p&gt;

&lt;p&gt;Thank you Dennis and Sebastian for teaching this class and showing me this framework. I certainly appreciate it and will be sure to start using it.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/tsqlt-unit-testing&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Yesterday, I attended a training class at Microsoft&#8217;s facility in Malvern, Pennsylvania.  This training class was led by Sebastian Meine (<a href="http://sqlity.net">sqlity.net</a>) and Dennis Lloyd (<a href="http://curiouslycorrect.com">curiouslycorrect.com</a>). </p>

<p>The class was from 9:00 am to 5:00 pm with a short break for lunch.  During the class, Dennis and Sebastian explained how to use tSQLt (<a href="http://tSQLt.org">http://tSQLt.org</a>) to write unit tests for your database code.  tSQLt is a frame work that can be freely downloaded and applied to your database, allowing you to quickly and easily write unit tests.  After learning about the framework and working through the exercises during the class, it is immediately obvious to me how this framework and the techniques explained during the class will benefit my organization.</p>

<p>Specifically, writing unit tests for the database will allow me to re-factor the code in a safe way, making sure that the code doesn&#8217;t break because I can easily run all of the unit tests for the database, or just the unit tests associated with the code I am in the process of changing.</p>

<p>Since I already have dozens of views, hundreds of functions and thousands of stored procedures, I cannot take the time to write all the unit tests required for the existing stuff, but I will create unit tests for the new code I write and also unit tests for any bug fixes with the existing code.  Over time I will have a set of unit tests for my database code that will undoubtedly allow me to spend less time fixing defects and more time writing new functionality.<br />
With my application, most of the bugs discovered by the end user are data related. The tSQLt unit testing framework will allow me to write tests for those bugs and then have confidence that the bug will not return (in the released version of the software).</p>

<p>Thank you Dennis and Sebastian for teaching this class and showing me this framework. I certainly appreciate it and will be sure to start using it.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/tsqlt-unit-testing">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/tsqlt-unit-testing#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1344</wfw:commentRss>
		</item>
				<item>
			<title>Understanding SQL Server 2000 Pivot with Aggregates</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/understanding-sql-server-2000-pivot</link>
			<pubDate>Tue, 08 Mar 2011 13:45:00 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>
<category domain="alt">Database Programming</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">1150@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/come-one-come-all-to&quot;&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/olap_1.gif&quot; align=&quot;left&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
This month&#039;s T-SQL Tuesday is being hosted by our very own, Jes Borland (&lt;a href=&quot;http://twitter.com/grrl_geek&quot;&gt;Twitter&lt;/a&gt; | &lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=420&quot;&gt;Blog&lt;/a&gt;).  Not only is she hosting this month but she is making it possible for LessThanDot&#039;s first T-SQL Tuesday event.  The topic that is brought to us is to discuss with everyone how we solved business problems with aggregate functions.  I thought this would be a good time to explain how you can write a pivot query in SQL 2000 using aggregate functions.  Writing a query is one thing, understanding how it works is another.  The goal of this blog post is to explain HOW it works so that it can be applied to other interesting problems.&lt;/p&gt;

&lt;p&gt;Why?  This database engine is 11 years old, why bother?  We are sometimes stuck dealing with an older database engine.   Understanding the concept behind this pivot will also allow you to use the technique in other interesting ways.  Personally, I think that by understanding how this works is another step in the process of &amp;#8220;thinking in sets&amp;#8221;.&lt;/p&gt;

&lt;p&gt;When we think of pivoting data, we usually want to see several rows of data displayed as additional columns.  Often times this is for reporting purposes or GUI displays within an application.&lt;/p&gt;

&lt;p&gt;This blog is meant to explain the process of pivoting the data.  Sure, many people know how to write a pivot query using aggregate functions, but how many people actually understand it from a set based perspective.  Understanding what the code is doing will help us to apply the principals to other queries.&lt;/p&gt;

&lt;p&gt;To explain this process, I will use a set of dummy data to aide in visualizing the data.  I will also build up to the final query, but examining each step along the way.&lt;/p&gt;

&lt;p&gt;The data:&lt;/p&gt;
&lt;pre&gt;
Id          Name                 Value
----------- -------------------- --------------------
1           Name                 George
1           ShoeSize             9.5

2           Name                 Bill
2           ShoeSize             10.5

3           Name                 John
3           ShoeSize             9

4           Name                 Greg
4           ShoeSize             9
&lt;/pre&gt;

&lt;p&gt;The data is relatively simple, but is meant to demonstrate the concept.  The goal of this blog is to explain how we can pivot the data shown above in to the following output.&lt;/p&gt;

&lt;pre&gt;
Id          Name                 ShoeSize
----------- -------------------- --------------------
1           George               9.5
2           Bill                 10.5
3           John                 9
4           Greg                 9
&lt;/pre&gt;

&lt;p&gt;As you can see, the original data had the name and shoe size for each person on separate rows.  The output has just a single row per person but with additional columns for the data.&lt;/p&gt;

&lt;p&gt;Setting up the code....&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb34486&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Create&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Table&lt;/span&gt; #Temp&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;Id &lt;span style=&quot;color: #0000FF;&quot;&gt;Int&lt;/span&gt;, Name &lt;span style=&quot;color: #0000FF;&quot;&gt;VarChar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;VarChar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Name&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;George&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ShoeSize&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;9.5&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Name&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Bill&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ShoeSize&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;10.5&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Name&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;John&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ShoeSize&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;9&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;4&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Name&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Greg&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Insert&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Into&lt;/span&gt; #Temp &lt;span style=&quot;color: #0000FF;&quot;&gt;Values&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;4&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ShoeSize&#039;&lt;/span&gt;,&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;9&#039;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb98791&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Our first query will simply show the data.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb30267&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; *&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt; &amp;nbsp; #Temp&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb31774&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Simple.  We see all the data in the table.  For our next step, let&#039;s set up the output structure.  We know we want to see the ID column and the Value column twice, once for the person&#039;s name and again for the shoe size. &lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb23128&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; Id,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt; &amp;nbsp; #Temp&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb49809&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;pre&gt;Id          Value                Value
----------- -------------------- --------------------
1           George               George
1           9.5                  9.5
2           Bill                 Bill
2           10.5                 10.5
3           John                 John
3           9                    9
4           Greg                 Greg
4           9                    9&lt;/pre&gt;

&lt;p&gt;This query is simply duplicating the data in two columns.  Ultimately, we will want the second column to show the person&#039;s name, and the third column to show the shoe size.  For the next step, let&#039;s show just the name in the second column and the shoe size in the third.  We will do this using a case expression:&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb54052&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; Id,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;When&lt;/span&gt; Name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Name&#039;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Then&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;When&lt;/span&gt; Name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ShoeSize&#039;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Then&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt; &amp;nbsp; #Temp&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb99271&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;pre&gt;
Id                               
----------- -------------------- --------------------
1           George               NULL
1           NULL                 9.5
2           Bill                 NULL
2           NULL                 10.5
3           John                 NULL
3           NULL                 9
4           Greg                 NULL
4           NULL                 9&lt;/pre&gt;

&lt;p&gt;Take a look at the case expression.  Notice that there is no ELSE clause.  Without an ELSE, the CASE expression will return NULL.  This is extremely important for our end result.  However, it&#039;s important to realize that the second column has the person&#039;s name and NULL, and the third column has shoe size and null.  Next we will introduce column aliases.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb62161&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; Id,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;When&lt;/span&gt; Name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Name&#039;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Then&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; Name,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0000FF;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;When&lt;/span&gt; Name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ShoeSize&#039;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Then&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; ShoeSize&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt; &amp;nbsp; #Temp&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb66508&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;pre&gt;
Id          Name                 ShoeSize
----------- -------------------- --------------------
1           George               NULL
1           NULL                 9.5
2           Bill                 NULL
2           NULL                 10.5
3           John                 NULL
3           NULL                 9
4           Greg                 NULL
4           NULL                 9&lt;/pre&gt;

&lt;p&gt;Nothing fancy here.  Just the column names.  We still have NULL&#039;s in our data that we will want to eliminate.  Which leads us to our next step, and the most important part, too.  When we use aggregates, it&#039;s important to realize that they ignore NULL&#039;s in the data.  For example, if we have 2 rows with &quot;George&quot; in one row and NULL in the other row, Max(Column) will ignore the NULL and return George.  We can use that to our advantage here.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb17856&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; Id,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #FF00FF;&quot;&gt;Min&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;When&lt;/span&gt; Name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Name&#039;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Then&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; Name,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #FF00FF;&quot;&gt;Min&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Case&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;When&lt;/span&gt; Name = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;ShoeSize&#039;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Then&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Value&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt; ShoeSize&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt; &amp;nbsp; #Temp&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Group&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;By&lt;/span&gt; Id&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb21676&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;pre&gt;
Id          Name                 ShoeSize
----------- -------------------- --------------------
1           George               9.5
2           Bill                 10.5
3           John                 9
4           Greg                 9
&lt;/pre&gt;

&lt;p&gt;As you can see, we finally got the results we wanted, effectively pivoting the data using code that will comfortably run in SQL2000 (and many other databases, too).&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/understanding-sql-server-2000-pivot&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/come-one-come-all-to"><img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/olap_1.gif" align="left" /></a><br />
This month's T-SQL Tuesday is being hosted by our very own, Jes Borland (<a href="http://twitter.com/grrl_geek">Twitter</a> | <a href="http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=420">Blog</a>).  Not only is she hosting this month but she is making it possible for LessThanDot's first T-SQL Tuesday event.  The topic that is brought to us is to discuss with everyone how we solved business problems with aggregate functions.  I thought this would be a good time to explain how you can write a pivot query in SQL 2000 using aggregate functions.  Writing a query is one thing, understanding how it works is another.  The goal of this blog post is to explain HOW it works so that it can be applied to other interesting problems.</p>

<p>Why?  This database engine is 11 years old, why bother?  We are sometimes stuck dealing with an older database engine.   Understanding the concept behind this pivot will also allow you to use the technique in other interesting ways.  Personally, I think that by understanding how this works is another step in the process of &#8220;thinking in sets&#8221;.</p>

<p>When we think of pivoting data, we usually want to see several rows of data displayed as additional columns.  Often times this is for reporting purposes or GUI displays within an application.</p>

<p>This blog is meant to explain the process of pivoting the data.  Sure, many people know how to write a pivot query using aggregate functions, but how many people actually understand it from a set based perspective.  Understanding what the code is doing will help us to apply the principals to other queries.</p>

<p>To explain this process, I will use a set of dummy data to aide in visualizing the data.  I will also build up to the final query, but examining each step along the way.</p>

<p>The data:</p>
<pre>
Id          Name                 Value
----------- -------------------- --------------------
1           Name                 George
1           ShoeSize             9.5

2           Name                 Bill
2           ShoeSize             10.5

3           Name                 John
3           ShoeSize             9

4           Name                 Greg
4           ShoeSize             9
</pre>

<p>The data is relatively simple, but is meant to demonstrate the concept.  The goal of this blog is to explain how we can pivot the data shown above in to the following output.</p>

<pre>
Id          Name                 ShoeSize
----------- -------------------- --------------------
1           George               9.5
2           Bill                 10.5
3           John                 9
4           Greg                 9
</pre>

<p>As you can see, the original data had the name and shoe size for each person on separate rows.  The output has just a single row per person but with additional columns for the data.</p>

<p>Setting up the code....</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb78775'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb78775','cb30897'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb78775" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Create</span> <span style="color: #0000FF;">Table</span> #Temp<span style="color: #808080;">&#40;</span>Id <span style="color: #0000FF;">Int</span>, Name <span style="color: #0000FF;">VarChar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">20</span><span style="color: #808080;">&#41;</span>, <span style="color: #0000FF;">Value</span> <span style="color: #0000FF;">VarChar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">20</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>, <span style="color: #FF0000;">'Name'</span>,<span style="color: #FF0000;">'George'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">1</span>, <span style="color: #FF0000;">'ShoeSize'</span>,<span style="color: #FF0000;">'9.5'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2</span>, <span style="color: #FF0000;">'Name'</span>,<span style="color: #FF0000;">'Bill'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2</span>, <span style="color: #FF0000;">'ShoeSize'</span>,<span style="color: #FF0000;">'10.5'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">3</span>, <span style="color: #FF0000;">'Name'</span>,<span style="color: #FF0000;">'John'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">3</span>, <span style="color: #FF0000;">'ShoeSize'</span>,<span style="color: #FF0000;">'9'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4</span>, <span style="color: #FF0000;">'Name'</span>,<span style="color: #FF0000;">'Greg'</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">Insert</span> <span style="color: #0000FF;">Into</span> #Temp <span style="color: #0000FF;">Values</span><span style="color: #808080;">&#40;</span><span style="color: #000;">4</span>, <span style="color: #FF0000;">'ShoeSize'</span>,<span style="color: #FF0000;">'9'</span><span style="color: #808080;">&#41;</span></li></ol></div><div id="cb30897" style="display: none; color: red;"></div></div></div>

<p>Our first query will simply show the data.</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb65709'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb65709','cb92100'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb65709" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Select</span> *</li><li style="" class="li2"><span style="color: #0000FF;">From</span> &nbsp; #Temp</li></ol></div><div id="cb92100" style="display: none; color: red;"></div></div></div>

<p>Simple.  We see all the data in the table.  For our next step, let's set up the output structure.  We know we want to see the ID column and the Value column twice, once for the person's name and again for the shoe size. </p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb42140'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb42140','cb97157'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb42140" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Select</span> Id,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000FF;">Value</span>,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000FF;">Value</span></li><li style="" class="li2"><span style="color: #0000FF;">From</span> &nbsp; #Temp</li></ol></div><div id="cb97157" style="display: none; color: red;"></div></div></div>

<pre>Id          Value                Value
----------- -------------------- --------------------
1           George               George
1           9.5                  9.5
2           Bill                 Bill
2           10.5                 10.5
3           John                 John
3           9                    9
4           Greg                 Greg
4           9                    9</pre>

<p>This query is simply duplicating the data in two columns.  Ultimately, we will want the second column to show the person's name, and the third column to show the shoe size.  For the next step, let's show just the name in the second column and the shoe size in the third.  We will do this using a case expression:</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb99759'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb99759','cb14776'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb99759" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Select</span> Id,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000FF;">Case</span> <span style="color: #0000FF;">When</span> Name = <span style="color: #FF0000;">'Name'</span> <span style="color: #0000FF;">Then</span> <span style="color: #0000FF;">Value</span> <span style="color: #0000FF;">End</span>,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000FF;">Case</span> <span style="color: #0000FF;">When</span> Name = <span style="color: #FF0000;">'ShoeSize'</span> <span style="color: #0000FF;">Then</span> <span style="color: #0000FF;">Value</span> <span style="color: #0000FF;">End</span></li><li style="" class="li2"><span style="color: #0000FF;">From</span> &nbsp; #Temp</li></ol></div><div id="cb14776" style="display: none; color: red;"></div></div></div>

<pre>
Id                               
----------- -------------------- --------------------
1           George               NULL
1           NULL                 9.5
2           Bill                 NULL
2           NULL                 10.5
3           John                 NULL
3           NULL                 9
4           Greg                 NULL
4           NULL                 9</pre>

<p>Take a look at the case expression.  Notice that there is no ELSE clause.  Without an ELSE, the CASE expression will return NULL.  This is extremely important for our end result.  However, it's important to realize that the second column has the person's name and NULL, and the third column has shoe size and null.  Next we will introduce column aliases.</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb91366'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb91366','cb63232'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb91366" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Select</span> Id,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000FF;">Case</span> <span style="color: #0000FF;">When</span> Name = <span style="color: #FF0000;">'Name'</span> <span style="color: #0000FF;">Then</span> <span style="color: #0000FF;">Value</span> <span style="color: #0000FF;">End</span> <span style="color: #0000FF;">As</span> Name,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000FF;">Case</span> <span style="color: #0000FF;">When</span> Name = <span style="color: #FF0000;">'ShoeSize'</span> <span style="color: #0000FF;">Then</span> <span style="color: #0000FF;">Value</span> <span style="color: #0000FF;">End</span> <span style="color: #0000FF;">As</span> ShoeSize</li><li style="" class="li2"><span style="color: #0000FF;">From</span> &nbsp; #Temp</li></ol></div><div id="cb63232" style="display: none; color: red;"></div></div></div>

<pre>
Id          Name                 ShoeSize
----------- -------------------- --------------------
1           George               NULL
1           NULL                 9.5
2           Bill                 NULL
2           NULL                 10.5
3           John                 NULL
3           NULL                 9
4           Greg                 NULL
4           NULL                 9</pre>

<p>Nothing fancy here.  Just the column names.  We still have NULL's in our data that we will want to eliminate.  Which leads us to our next step, and the most important part, too.  When we use aggregates, it's important to realize that they ignore NULL's in the data.  For example, if we have 2 rows with "George" in one row and NULL in the other row, Max(Column) will ignore the NULL and return George.  We can use that to our advantage here.</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb5840'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb5840','cb3754'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb5840" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Select</span> Id,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">Min</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">Case</span> <span style="color: #0000FF;">When</span> Name = <span style="color: #FF0000;">'Name'</span> <span style="color: #0000FF;">Then</span> <span style="color: #0000FF;">Value</span> <span style="color: #0000FF;">End</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">As</span> Name,</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">Min</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">Case</span> <span style="color: #0000FF;">When</span> Name = <span style="color: #FF0000;">'ShoeSize'</span> <span style="color: #0000FF;">Then</span> <span style="color: #0000FF;">Value</span> <span style="color: #0000FF;">End</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">As</span> ShoeSize</li><li style="" class="li2"><span style="color: #0000FF;">From</span> &nbsp; #Temp</li><li style="" class="li1"><span style="color: #0000FF;">Group</span> <span style="color: #0000FF;">By</span> Id</li></ol></div><div id="cb3754" style="display: none; color: red;"></div></div></div>

<pre>
Id          Name                 ShoeSize
----------- -------------------- --------------------
1           George               9.5
2           Bill                 10.5
3           John                 9
4           Greg                 9
</pre>

<p>As you can see, we finally got the results we wanted, effectively pivoting the data using code that will comfortably run in SQL2000 (and many other databases, too).</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/understanding-sql-server-2000-pivot">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/understanding-sql-server-2000-pivot#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1150</wfw:commentRss>
		</item>
				<item>
			<title>T-SQL Tuesday #13: Is that what you really want?</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/t-sql-tuesday-13-is-that-what-you-really</link>
			<pubDate>Tue, 14 Dec 2010 14:30:23 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>
<category domain="alt">Database Programming</category>			<guid isPermaLink="false">1046@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;&lt;a href=&quot;http://www.sqlservercentral.com/blogs/steve_jones/archive/2010/12/07/t_2D00_sql-tuesday-_2300_13-_2D00_-what-the-business-says-is-not-what-the-business-wants.aspx&quot;&gt;&lt;/p&gt;&lt;div class=&quot;image_block&quot;&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/DataMgmt/olap_1.gif&quot; alt=&quot;&quot; title=&quot;&quot; width=&quot;154&quot; height=&quot;154&quot; align=&quot;left&quot; /&gt;&lt;/div&gt;&lt;/a&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Steve Jones (&lt;a href=&quot;http://twitter.com/way0utwest&quot;&gt;Twitter&lt;/a&gt; | &lt;a href=&quot;http://www.sqlservercentral.com/blogs/steve_jones/default.aspx&quot;&gt;Blog&lt;/a&gt;), The Voice of the DBA, is hosting the T-SQL Tuesday blogging fest over on &lt;a href=&quot;http://www.sqlservercentral.com/blogs/steve_jones/archive/2010/12/07/t_2D00_sql-tuesday-_2300_13-_2D00_-what-the-business-says-is-not-what-the-business-wants.aspx&quot;&gt;SQLServerCentral.com&lt;/a&gt; this month.  This months topic involves businesses and what they really want.&lt;br /&gt;
&lt;br /&gt;
As many of you know, I am the owner of a small software company that satisfies a niche market.  I&#039;ve been in business for 13 years now, and am still working on the same core application.  I constantly find new features and functionality to offer in the app, continually improving it for the benefit of my customers.  I think it&#039;s safe to say that I understand the technical challenge that my software accommodates, as well as the business implications involved.  I also have a very good appreciation for the logistics involved in the business process, and the most efficient ways to accomplish the business goals.&lt;br /&gt;
&lt;br /&gt;
Occasionally, we will come across a customer that thinks their method of accomplishing the business&#039;s goals is the only correct one, even though my experience clearly indicates there is a better (more efficient) way.  I was talking to Ted/onpnt (&lt;a href=&quot;http://twitter.com/onpnt&quot;&gt;Twitter&lt;/a&gt; | &lt;a href=&quot;http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;amp;author=68&quot;&gt;Blog&lt;/a&gt;) yesterday about this very same topic.  The conversation went something like this:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;George:&lt;/strong&gt; You should see the frickin hoops I gotta jump through for this one customer. I feel like a whipping boy.&lt;br /&gt;
&lt;strong&gt;Ted:&lt;/strong&gt; what did they have you doing??&lt;br /&gt;
&lt;strong&gt;George:&lt;/strong&gt; They refuse to use (software) they way it was intended. They want a &quot;Blah Blah Report&quot; where each..... This report is not accurate because (software) wasn&#039;t designed this way. Instead, each... then a report showing... should be used instead.&lt;br /&gt;
&lt;strong&gt;Ted:&lt;/strong&gt; so they want you to write a report that doesn&#039;t even reflect the way the system works.&lt;br /&gt;
&lt;strong&gt;George:&lt;/strong&gt; It&#039;s like.... well.... trying to use Excel to manage a sql database.&lt;br /&gt;
&lt;strong&gt;Ted:&lt;/strong&gt; LOL&lt;br /&gt;
&lt;strong&gt;George:&lt;/strong&gt; Yeah. Write a report that magically gets info, never makes a mistake, and base it all on completely unrelated information.&lt;br /&gt;
&lt;strong&gt;Ted:&lt;/strong&gt; LOL&lt;br /&gt;
&lt;strong&gt;George:&lt;/strong&gt; oh.... and I&#039;m supposed to make it faster, too.&lt;br /&gt;
&lt;strong&gt;Ted:&lt;/strong&gt; ROFL but of course!&lt;br /&gt;
&lt;br /&gt;
Whenever I run in to a problem with a customer, I try to use the following steps.&lt;br /&gt;
&lt;br /&gt;
1. Manage expectations at the beginning.  This allows you to prevent possible complications in the future by expressing what the customer should reasonably expect from the software.&lt;br /&gt;
&lt;br /&gt;
2. Effectively train the customer in the proper operation of the software.  Part of the training process should be the &quot;big picture&quot; because it allows them to see and appreciate your methods for handling the business problems in an efficient manner.&lt;br /&gt;
&lt;br /&gt;
3. When a customer has unrealistic expectations, it&#039;s important to explain (at a high level) why they are unrealistic.  Explain the benefits of the currently implemented method and the draw backs with their proposed method.&lt;br /&gt;
&lt;br /&gt;
4. When they insist on new/different functionality, you should attempt to work out a compromise that allows your existing functionality to satisfy their requirements.  Often times, a small tweak to current functionality will satisfy their requirements.&lt;br /&gt;
&lt;br /&gt;
5. When all else fails, the customer is always right.  If you refuse to implement the functionality they want, you run the risk of losing their business, and potentially word-of-mouth business as well.&lt;br /&gt;
&lt;br /&gt;
As developers, we have a responsibility to provide software that makes our customers job easier and more efficient.  We also have a responsibility to advise them of alternative methods (new to them) that would improve their efficiency.  If all else fails, be prepared to give the customer what they want.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/t-sql-tuesday-13-is-that-what-you-really&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p><a href="http://www.sqlservercentral.com/blogs/steve_jones/archive/2010/12/07/t_2D00_sql-tuesday-_2300_13-_2D00_-what-the-business-says-is-not-what-the-business-wants.aspx"></p><div class="image_block"><img src="http://blogs.lessthandot.com/media/blogs/DataMgmt/olap_1.gif" alt="" title="" width="154" height="154" align="left" /></div></a><p><br /><br /></p><p>Steve Jones (<a href="http://twitter.com/way0utwest">Twitter</a> | <a href="http://www.sqlservercentral.com/blogs/steve_jones/default.aspx">Blog</a>), The Voice of the DBA, is hosting the T-SQL Tuesday blogging fest over on <a href="http://www.sqlservercentral.com/blogs/steve_jones/archive/2010/12/07/t_2D00_sql-tuesday-_2300_13-_2D00_-what-the-business-says-is-not-what-the-business-wants.aspx">SQLServerCentral.com</a> this month.  This months topic involves businesses and what they really want.<br />
<br />
As many of you know, I am the owner of a small software company that satisfies a niche market.  I've been in business for 13 years now, and am still working on the same core application.  I constantly find new features and functionality to offer in the app, continually improving it for the benefit of my customers.  I think it's safe to say that I understand the technical challenge that my software accommodates, as well as the business implications involved.  I also have a very good appreciation for the logistics involved in the business process, and the most efficient ways to accomplish the business goals.<br />
<br />
Occasionally, we will come across a customer that thinks their method of accomplishing the business's goals is the only correct one, even though my experience clearly indicates there is a better (more efficient) way.  I was talking to Ted/onpnt (<a href="http://twitter.com/onpnt">Twitter</a> | <a href="http://blogs.lessthandot.com/index.php/All/?disp=authdir&amp;author=68">Blog</a>) yesterday about this very same topic.  The conversation went something like this:<br />
<br />
<strong>George:</strong> You should see the frickin hoops I gotta jump through for this one customer. I feel like a whipping boy.<br />
<strong>Ted:</strong> what did they have you doing??<br />
<strong>George:</strong> They refuse to use (software) they way it was intended. They want a "Blah Blah Report" where each..... This report is not accurate because (software) wasn't designed this way. Instead, each... then a report showing... should be used instead.<br />
<strong>Ted:</strong> so they want you to write a report that doesn't even reflect the way the system works.<br />
<strong>George:</strong> It's like.... well.... trying to use Excel to manage a sql database.<br />
<strong>Ted:</strong> LOL<br />
<strong>George:</strong> Yeah. Write a report that magically gets info, never makes a mistake, and base it all on completely unrelated information.<br />
<strong>Ted:</strong> LOL<br />
<strong>George:</strong> oh.... and I'm supposed to make it faster, too.<br />
<strong>Ted:</strong> ROFL but of course!<br />
<br />
Whenever I run in to a problem with a customer, I try to use the following steps.<br />
<br />
1. Manage expectations at the beginning.  This allows you to prevent possible complications in the future by expressing what the customer should reasonably expect from the software.<br />
<br />
2. Effectively train the customer in the proper operation of the software.  Part of the training process should be the "big picture" because it allows them to see and appreciate your methods for handling the business problems in an efficient manner.<br />
<br />
3. When a customer has unrealistic expectations, it's important to explain (at a high level) why they are unrealistic.  Explain the benefits of the currently implemented method and the draw backs with their proposed method.<br />
<br />
4. When they insist on new/different functionality, you should attempt to work out a compromise that allows your existing functionality to satisfy their requirements.  Often times, a small tweak to current functionality will satisfy their requirements.<br />
<br />
5. When all else fails, the customer is always right.  If you refuse to implement the functionality they want, you run the risk of losing their business, and potentially word-of-mouth business as well.<br />
<br />
As developers, we have a responsibility to provide software that makes our customers job easier and more efficient.  We also have a responsibility to advise them of alternative methods (new to them) that would improve their efficiency.  If all else fails, be prepared to give the customer what they want.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/t-sql-tuesday-13-is-that-what-you-really">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/t-sql-tuesday-13-is-that-what-you-really#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=1046</wfw:commentRss>
		</item>
				<item>
			<title>SQLCop update Version 1.1</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sqlcop-update-version-1-1</link>
			<pubDate>Mon, 23 Aug 2010 12:51:00 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="alt">Database Programming</category>
<category domain="main">Database Administration</category>
<category domain="alt">Microsoft SQL Server Admin</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">937@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;This version of &lt;a href=&quot;http://sqlcop.lessthandot.com/&quot;&gt;SQLCop&lt;/a&gt; contains several bug fixes as well as some new features.  Many of the items changed in this version were based on feedback received by you, our users.  We encourage people to post comments so that we can improve the application.&lt;/p&gt;

&lt;p&gt;If you previously downloaded the original version of SQLCop, you should manually download and install this new version: &lt;a href=&quot;http://sqlcop.lessthandot.com/&quot;&gt;http://sqlcop.lessthandot.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fixes:&lt;/strong&gt;&lt;br /&gt;
1. This version of SQL Cop works with databases that have a binary collation.&lt;/p&gt;

&lt;p&gt;2. There was a &quot;load nodes&quot; problem that occurred when your firewall was blocking your connection to our site.  This version of the application does require an internet connection the first time it is run so that an XML file can be downloaded.  After this first download, you no longer need an internet connection.  Without a connection to the internet, you will not see the blog or wiki article that explains the problems, but you will still be able to list the occurrences of the problem in your database.&lt;/p&gt;

&lt;p&gt;3. A database connection parameter was changed which will allow SQL Cop to run quicker.&lt;/p&gt;

&lt;p&gt;4. Some people were seeing &quot;stub&quot; instead of &quot;No Problems Found&quot;.  This item has been corrected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Updates&lt;/strong&gt;&lt;br /&gt;
SQL Cop now checks a very small XML file on startup that is located on our server.  If the connection to the server fails, the local version of the issues XML file is used.  If SQL Cop can download the configuration xml file, we compare versions of the application and versions of the issues xml.  If there is a new application, the user is notified and prompted to download the newer version.  If there is a newer version of the issues xml file, it is downloaded and stored automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Checks&lt;/strong&gt;&lt;br /&gt;
We added new checks for:&lt;br /&gt;
Code&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Procedures with dynamic sql&lt;/li&gt;
&lt;li&gt;Procedures using dynamic sql without sp_executesql&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Table/View&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Unnamed Constraints&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Indexes&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Forwarded Records&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Configuration&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ad Hoc Distributed Queries&lt;/li&gt;
&lt;li&gt;CLR&lt;/li&gt;
&lt;li&gt;Database and log files on the same physical disk&lt;/li&gt;
&lt;li&gt;Database Mail&lt;/li&gt;
&lt;li&gt;Deprecated Features&lt;/li&gt;
&lt;li&gt;Instant File Initialization&lt;/li&gt;
&lt;li&gt;Max Degree of Parallelism&lt;/li&gt;
&lt;li&gt;OLE Automation Procedures&lt;/li&gt;
&lt;li&gt;Service Account&lt;/li&gt;
&lt;li&gt;SMO and DMO&lt;/li&gt;
&lt;li&gt;SQL Server Agent Service&lt;/li&gt;
&lt;li&gt;xp cmdshell&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A new category was added for Health with the following checks.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Buffer cache hit ratio&lt;/li&gt;
&lt;li&gt;Page life expectancy&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;This brings the total number of issues checked to 50 for SQL 2008 and 49 for SQL 2005.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sqlcop-update-version-1-1&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>This version of <a href="http://sqlcop.lessthandot.com/">SQLCop</a> contains several bug fixes as well as some new features.  Many of the items changed in this version were based on feedback received by you, our users.  We encourage people to post comments so that we can improve the application.</p>

<p>If you previously downloaded the original version of SQLCop, you should manually download and install this new version: <a href="http://sqlcop.lessthandot.com/">http://sqlcop.lessthandot.com/</a></p>

<p><strong>Fixes:</strong><br />
1. This version of SQL Cop works with databases that have a binary collation.</p>

<p>2. There was a "load nodes" problem that occurred when your firewall was blocking your connection to our site.  This version of the application does require an internet connection the first time it is run so that an XML file can be downloaded.  After this first download, you no longer need an internet connection.  Without a connection to the internet, you will not see the blog or wiki article that explains the problems, but you will still be able to list the occurrences of the problem in your database.</p>

<p>3. A database connection parameter was changed which will allow SQL Cop to run quicker.</p>

<p>4. Some people were seeing "stub" instead of "No Problems Found".  This item has been corrected.</p>

<p><strong>Updates</strong><br />
SQL Cop now checks a very small XML file on startup that is located on our server.  If the connection to the server fails, the local version of the issues XML file is used.  If SQL Cop can download the configuration xml file, we compare versions of the application and versions of the issues xml.  If there is a new application, the user is notified and prompted to download the newer version.  If there is a newer version of the issues xml file, it is downloaded and stored automatically.</p>

<p><strong>Checks</strong><br />
We added new checks for:<br />
Code</p>
<ul><li>Procedures with dynamic sql</li>
<li>Procedures using dynamic sql without sp_executesql</li></ul>

<p>Table/View</p>
<ul><li>Unnamed Constraints</li></ul>

<p>Indexes</p>
<ul><li>Forwarded Records</li></ul>

<p>Configuration</p>
<ul>
<li>Ad Hoc Distributed Queries</li>
<li>CLR</li>
<li>Database and log files on the same physical disk</li>
<li>Database Mail</li>
<li>Deprecated Features</li>
<li>Instant File Initialization</li>
<li>Max Degree of Parallelism</li>
<li>OLE Automation Procedures</li>
<li>Service Account</li>
<li>SMO and DMO</li>
<li>SQL Server Agent Service</li>
<li>xp cmdshell</li>
</ul>

<p>A new category was added for Health with the following checks.</p>
<ul><li>Buffer cache hit ratio</li>
<li>Page life expectancy</li></ul>

<p>This brings the total number of issues checked to 50 for SQL 2008 and 49 for SQL 2005.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sqlcop-update-version-1-1">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBAdmin/sqlcop-update-version-1-1#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=937</wfw:commentRss>
		</item>
				<item>
			<title>SQL Server Proper Case Function</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/sql-server-proper-case-function</link>
			<pubDate>Wed, 24 Feb 2010 11:34:43 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Database Programming</category>
<category domain="alt">Microsoft SQL Server</category>			<guid isPermaLink="false">759@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;SQL Server (T-SQL specifically) is not usually the best place to write a function for modifying the case of your data. String functions are generally slow and often a bit cumbersome to implement.  That being said, it&#039;s not uncommon to have data in your tables that needs to be &quot;cleaned up a bit&quot;.  In situations like this, it is acceptable to write and use a function like this.&lt;/p&gt;

&lt;p&gt;With SQL, it is easy to convert strings to upper case or lower case, but what about making it mixed case/title case.  This functionality is useful in many different situations.  There are many examples on the internet that show how this can be done.  Some work better than others, and perform better than others.  The simplest versions of this will loop through a string, character by character, and capitalize anything following a space.  Unfortunately, this is not always adequate.&lt;/p&gt;

&lt;p&gt;I have developed a method that actively seeks out any character that is not a letter.  Under certain circumstances, this is more appropriate because it satisfies more situations. This method also reduces the number of loops that need to be executed by using the PatIndex function and looking for non-alpha characters followed by lower case alpha characters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;General theory:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Like I stated earlier, this code actively seeks out data from within the string that needs to be changed.  The first thing we do is convert the string to lower case except for the first character, which is converted to upper case.  For example, suppose you have this:  THIS IS-ALL &quot;Caps&quot;&lt;/p&gt;

&lt;p&gt;At the beginning of the function, we convert to lower case except for the first character, so it becomes:&lt;/p&gt;

&lt;p&gt;This is-all &quot;caps&quot;&lt;/p&gt;

&lt;p&gt;Next, we actively seek out positions where one character is non-alphabetic followed by a lower case alphabetic character.   In this case, we would return character position 5 (space followed by lower case i).  We then use the stuff function to convert this to upper case.  This would result in:&lt;/p&gt;

&lt;p&gt;This Is-all &quot;caps&quot;&lt;/p&gt;

&lt;p&gt;We then repeat this process until there are no more occurrences of non-alpha followed by lower case alpha characters.&lt;/p&gt;

&lt;p&gt;This code uses several functions, some that you may not be familiar with.  Upper converts characters to upper case.  Lower converts characters to lower case.  SubString allows you to retrieve data from the middle of string.  The less common functions here are PatIndex and Stuff.&lt;/p&gt;

&lt;p&gt;PatIndex searches through a string and returns the position where a search pattern is found.  In our case, we want to find a &quot;non-alpha character followed by a lower case alpha character&quot;.  By default, searches are not case sensitive.  This is actually controlled by the collation of your database.  You can get case sensitive searches by using a binary collation.  For this function, I use:&lt;/p&gt;

&lt;p&gt;PatIndex(&#039;%[^a-zA-Z][a-z]%&#039;, @Data COLLATE Latin1_General_Bin)&lt;/p&gt;

&lt;p&gt;The other function I use here is stuff.  Stuff can be used to insert text in to the middle of a string.  It can also be used similar to a Replace function.  With replace, you essentially replace all occurrences of one string with another.  Stuff is different in that you can replace data based on its position within a string without regard to what is at that position.   For example:&lt;/p&gt;

&lt;p&gt;Select Stuff(&#039;lower case&#039;, 7, 1, &#039;C&#039;)&lt;/p&gt;

&lt;p&gt;Notice how the 7th character (the lower case c) is replaced with an upper case C.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb92192&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Create&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;Function&lt;/span&gt; dbo.&lt;span style=&quot;color: #202020;&quot;&gt;Proper&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;@&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;VarChar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;8000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Returns&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;VarChar&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000;&quot;&gt;8000&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;As&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;Begin&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Declare&lt;/span&gt; @Position &lt;span style=&quot;color: #0000FF;&quot;&gt;Int&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt; = &lt;span style=&quot;color: #FF00FF;&quot;&gt;Stuff&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;Lower&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;@&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #FF00FF;&quot;&gt;Upper&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;Left&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;@&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt;, &lt;span style=&quot;color: #000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Position = &lt;span style=&quot;color: #FF00FF;&quot;&gt;PatIndex&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;%[^a-zA-Z][a-z]%&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;COLLATE&lt;/span&gt; Latin1_General_Bin&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;While&lt;/span&gt; @Position &amp;gt; &lt;span style=&quot;color: #000;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Select&lt;/span&gt; @&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt; = &lt;span style=&quot;color: #FF00FF;&quot;&gt;Stuff&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;@&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt;, @Position, &lt;span style=&quot;color: #000;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #FF00FF;&quot;&gt;Upper&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF00FF;&quot;&gt;SubString&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;@&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt;, @Position, &lt;span style=&quot;color: #000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;@Position = &lt;span style=&quot;color: #FF00FF;&quot;&gt;PatIndex&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;%[^a-zA-Z][a-z]%&#039;&lt;/span&gt;, @&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;COLLATE&lt;/span&gt; Latin1_General_Bin&lt;span style=&quot;color: #808080;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;Return&lt;/span&gt; @&lt;span style=&quot;color: #0000FF;&quot;&gt;Data&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb82751&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In my opinion, there are several things that make this function better.  It will correctly capitalize all words and it minimizes the number of loops.  In fact, it will loop just once for each word that needs to be capitalized.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/sql-server-proper-case-function&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>SQL Server (T-SQL specifically) is not usually the best place to write a function for modifying the case of your data. String functions are generally slow and often a bit cumbersome to implement.  That being said, it's not uncommon to have data in your tables that needs to be "cleaned up a bit".  In situations like this, it is acceptable to write and use a function like this.</p>

<p>With SQL, it is easy to convert strings to upper case or lower case, but what about making it mixed case/title case.  This functionality is useful in many different situations.  There are many examples on the internet that show how this can be done.  Some work better than others, and perform better than others.  The simplest versions of this will loop through a string, character by character, and capitalize anything following a space.  Unfortunately, this is not always adequate.</p>

<p>I have developed a method that actively seeks out any character that is not a letter.  Under certain circumstances, this is more appropriate because it satisfies more situations. This method also reduces the number of loops that need to be executed by using the PatIndex function and looking for non-alpha characters followed by lower case alpha characters.</p>

<p><strong>General theory:</strong></p>

<p>Like I stated earlier, this code actively seeks out data from within the string that needs to be changed.  The first thing we do is convert the string to lower case except for the first character, which is converted to upper case.  For example, suppose you have this:  THIS IS-ALL "Caps"</p>

<p>At the beginning of the function, we convert to lower case except for the first character, so it becomes:</p>

<p>This is-all "caps"</p>

<p>Next, we actively seek out positions where one character is non-alphabetic followed by a lower case alphabetic character.   In this case, we would return character position 5 (space followed by lower case i).  We then use the stuff function to convert this to upper case.  This would result in:</p>

<p>This Is-all "caps"</p>

<p>We then repeat this process until there are no more occurrences of non-alpha followed by lower case alpha characters.</p>

<p>This code uses several functions, some that you may not be familiar with.  Upper converts characters to upper case.  Lower converts characters to lower case.  SubString allows you to retrieve data from the middle of string.  The less common functions here are PatIndex and Stuff.</p>

<p>PatIndex searches through a string and returns the position where a search pattern is found.  In our case, we want to find a "non-alpha character followed by a lower case alpha character".  By default, searches are not case sensitive.  This is actually controlled by the collation of your database.  You can get case sensitive searches by using a binary collation.  For this function, I use:</p>

<p>PatIndex('%[^a-zA-Z][a-z]%', @Data COLLATE Latin1_General_Bin)</p>

<p>The other function I use here is stuff.  Stuff can be used to insert text in to the middle of a string.  It can also be used similar to a Replace function.  With replace, you essentially replace all occurrences of one string with another.  Stuff is different in that you can replace data based on its position within a string without regard to what is at that position.   For example:</p>

<p>Select Stuff('lower case', 7, 1, 'C')</p>

<p>Notice how the 7th character (the lower case c) is replaced with an upper case C.</p>

<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb56026'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb56026','cb23590'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb56026" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">Create</span> <span style="color: #0000FF;">Function</span> dbo.<span style="color: #202020;">Proper</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Data</span> <span style="color: #0000FF;">VarChar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">8000</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span></li><li style="" class="li2"><span style="color: #0000FF;">Returns</span> <span style="color: #0000FF;">VarChar</span><span style="color: #808080;">&#40;</span><span style="color: #000;">8000</span><span style="color: #808080;">&#41;</span></li><li style="" class="li1"><span style="color: #0000FF;">As</span></li><li style="" class="li2"><span style="color: #0000FF;">Begin</span></li><li style="" class="li1">&nbsp; <span style="color: #0000FF;">Declare</span> @Position <span style="color: #0000FF;">Int</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; <span style="color: #0000FF;">Select</span> @<span style="color: #0000FF;">Data</span> = <span style="color: #FF00FF;">Stuff</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">Lower</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Data</span><span style="color: #808080;">&#41;</span>, <span style="color: #000;">1</span>, <span style="color: #000;">1</span>, <span style="color: #FF00FF;">Upper</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">Left</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Data</span>, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@Position = <span style="color: #FF00FF;">PatIndex</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%[^a-zA-Z][a-z]%'</span>, @<span style="color: #0000FF;">Data</span> <span style="color: #0000FF;">COLLATE</span> Latin1_General_Bin<span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; <span style="color: #0000FF;">While</span> @Position &gt; <span style="color: #000;">0</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0000FF;">Select</span> @<span style="color: #0000FF;">Data</span> = <span style="color: #FF00FF;">Stuff</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Data</span>, @Position, <span style="color: #000;">2</span>, <span style="color: #FF00FF;">Upper</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SubString</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Data</span>, @Position, <span style="color: #000;">2</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@Position = <span style="color: #FF00FF;">PatIndex</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%[^a-zA-Z][a-z]%'</span>, @<span style="color: #0000FF;">Data</span> <span style="color: #0000FF;">COLLATE</span> Latin1_General_Bin<span style="color: #808080;">&#41;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; <span style="color: #0000FF;">Return</span> @<span style="color: #0000FF;">Data</span></li><li style="" class="li1"><span style="color: #0000FF;">End</span></li></ol></div><div id="cb23590" style="display: none; color: red;"></div></div></div>

<p>In my opinion, there are several things that make this function better.  It will correctly capitalize all words and it minimizes the number of loops.  In fact, it will loop just once for each word that needs to be capitalized.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/sql-server-proper-case-function">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/sql-server-proper-case-function#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=759</wfw:commentRss>
		</item>
				<item>
			<title>Missing foreign key constraints</title>
			<link>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/missing-foreign-key-constraints</link>
			<pubDate>Fri, 20 Nov 2009 11:32:30 +0000</pubDate>			<dc:creator>George Mastros (gmmastros)</dc:creator>
			<category domain="main">Data Modelling &amp; Design</category>			<guid isPermaLink="false">684@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;References are at the heart of a database.  It is possible to create a beautiful database with perfectly working front end code that always, 100% of the time, does the right thing with your data.  But, writing code is hard.  Very hard!  Your data is often the most important asset you own.  You need to protect it with every bit of technology you can find.  At the heart of protecting your data is referential integrity.  What does this mean?  It means that you shouldn&#039;t be missing data, ever!  &lt;/p&gt;

&lt;p&gt;The code below will check for columns that have ID in the name of the column where that column is not part of a primary key or foreign key constraint.  Often times, this represents a missing constraint, but not always.  The code presented below exists to highlight potential problems.  You must still determine if this potential problem is real, and then act accordingly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to detect this problem:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;tsql&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;tsql&quot; id=&quot;cb55766&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;SELECT&lt;/span&gt; &amp;nbsp;C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_SCHEMA&lt;/span&gt;,C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_NAME&lt;/span&gt;,C.&lt;span style=&quot;color: #202020;&quot;&gt;COLUMN_NAME&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;FROM&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #00AF00;&quot;&gt;INFORMATION_SCHEMA&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;COLUMNS&lt;/span&gt; C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;INNER&lt;/span&gt; Join &lt;span style=&quot;color: #00AF00;&quot;&gt;INFORMATION_SCHEMA&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;TABLES&lt;/span&gt; T &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_NAME&lt;/span&gt; = T.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_NAME&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And T.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_TYPE&lt;/span&gt; = &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;Base Table&#039;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AND T.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_SCHEMA&lt;/span&gt; = C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_SCHEMA&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF00FF;&quot;&gt;LEFT&lt;/span&gt; Join &lt;span style=&quot;color: #00AF00;&quot;&gt;INFORMATION_SCHEMA&lt;/span&gt;.&lt;span style=&quot;color: #00AF00;&quot;&gt;CONSTRAINT_COLUMN_USAGE&lt;/span&gt; U &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;ON&lt;/span&gt; C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_NAME&lt;/span&gt; = U.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_NAME&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And C.&lt;span style=&quot;color: #202020;&quot;&gt;COLUMN_NAME&lt;/span&gt; = U.&lt;span style=&quot;color: #202020;&quot;&gt;COLUMN_NAME&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And U.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_SCHEMA&lt;/span&gt; = C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_SCHEMA&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;WHERE&lt;/span&gt; &amp;nbsp; U.&lt;span style=&quot;color: #202020;&quot;&gt;COLUMN_NAME&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;IS&lt;/span&gt; Null &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; And C.&lt;span style=&quot;color: #202020;&quot;&gt;COLUMN_NAME&lt;/span&gt; Like &lt;span style=&quot;color: #FF0000;&quot;&gt;&#039;%id&#039;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ORDER&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;BY&lt;/span&gt; C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_SCHEMA&lt;/span&gt;, C.&lt;span style=&quot;color: #202020;&quot;&gt;TABLE_NAME&lt;/span&gt;, C.&lt;span style=&quot;color: #202020;&quot;&gt;COLUMN_NAME&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb49889&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to correct it:&lt;/strong&gt; Correcting this problem seems simple at first.  Just declare your foreign keys, right?  Well, it&#039;s not so simple.  You see, there could be code running that deletes all the necessary data from the related tables.  If you have code that deletes data in related tables in the wrong order, you will get referential constraint errors.  Similar problems can occur with updates and inserts.  The order in which you do things is important when you have referential constraints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Level of severity:&lt;/strong&gt; High&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Level of difficulty:&lt;/strong&gt; High&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/missing-foreign-key-constraints&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>References are at the heart of a database.  It is possible to create a beautiful database with perfectly working front end code that always, 100% of the time, does the right thing with your data.  But, writing code is hard.  Very hard!  Your data is often the most important asset you own.  You need to protect it with every bit of technology you can find.  At the heart of protecting your data is referential integrity.  What does this mean?  It means that you shouldn't be missing data, ever!  </p>

<p>The code below will check for columns that have ID in the name of the column where that column is not part of a primary key or foreign key constraint.  Often times, this represents a missing constraint, but not always.  The code presented below exists to highlight potential problems.  You must still determine if this potential problem is real, and then act accordingly.</p>

<p><strong>How to detect this problem:</strong></p>
<div class="codebox"><div class="codeheader"><span>tsql</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb58076'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb58076','cb54558'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="tsql" id="cb58076" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0000FF;">SELECT</span> &nbsp;C.<span style="color: #202020;">TABLE_SCHEMA</span>,C.<span style="color: #202020;">TABLE_NAME</span>,C.<span style="color: #202020;">COLUMN_NAME</span></li><li style="" class="li2"><span style="color: #0000FF;">FROM</span> &nbsp; &nbsp;<span style="color: #00AF00;">INFORMATION_SCHEMA</span>.<span style="color: #00AF00;">COLUMNS</span> C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">INNER</span> Join <span style="color: #00AF00;">INFORMATION_SCHEMA</span>.<span style="color: #00AF00;">TABLES</span> T &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ON</span> C.<span style="color: #202020;">TABLE_NAME</span> = T.<span style="color: #202020;">TABLE_NAME</span> &nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And T.<span style="color: #202020;">TABLE_TYPE</span> = <span style="color: #FF0000;">'Base Table'</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND T.<span style="color: #202020;">TABLE_SCHEMA</span> = C.<span style="color: #202020;">TABLE_SCHEMA</span> &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF00FF;">LEFT</span> Join <span style="color: #00AF00;">INFORMATION_SCHEMA</span>.<span style="color: #00AF00;">CONSTRAINT_COLUMN_USAGE</span> U &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ON</span> C.<span style="color: #202020;">TABLE_NAME</span> = U.<span style="color: #202020;">TABLE_NAME</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And C.<span style="color: #202020;">COLUMN_NAME</span> = U.<span style="color: #202020;">COLUMN_NAME</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And U.<span style="color: #202020;">TABLE_SCHEMA</span> = C.<span style="color: #202020;">TABLE_SCHEMA</span></li><li style="" class="li1"><span style="color: #0000FF;">WHERE</span> &nbsp; U.<span style="color: #202020;">COLUMN_NAME</span> <span style="color: #0000FF;">IS</span> Null &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; And C.<span style="color: #202020;">COLUMN_NAME</span> Like <span style="color: #FF0000;">'%id'</span></li><li style="" class="li1"><span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> C.<span style="color: #202020;">TABLE_SCHEMA</span>, C.<span style="color: #202020;">TABLE_NAME</span>, C.<span style="color: #202020;">COLUMN_NAME</span></li></ol></div><div id="cb54558" style="display: none; color: red;"></div></div></div>

<p><strong>How to correct it:</strong> Correcting this problem seems simple at first.  Just declare your foreign keys, right?  Well, it's not so simple.  You see, there could be code running that deletes all the necessary data from the related tables.  If you have code that deletes data in related tables in the wrong order, you will get referential constraint errors.  Similar problems can occur with updates and inserts.  The order in which you do things is important when you have referential constraints.</p>

<p><strong>Level of severity:</strong> High</p>

<p><strong>Level of difficulty:</strong> High</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/missing-foreign-key-constraints">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/missing-foreign-key-constraints#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/DataMgmt/?tempskin=_rss2&#38;disp=comments&#38;p=684</wfw:commentRss>
		</item>
			</channel>
</rss>
