<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8254475978080599910</id><updated>2011-07-08T12:26:26.732-04:00</updated><title type='text'>SireeS SQL Server Impresssions</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>39</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-1843938805044261039</id><published>2009-10-01T20:47:00.003-04:00</published><updated>2009-10-02T13:20:52.559-04:00</updated><title type='text'>When to Reorganize/Rebuild Index</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} table.MsoTableGrid 	{mso-style-name:"Table Grid"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	border:solid windowtext 1.0pt; 	mso-border-alt:solid windowtext .5pt; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-border-insideh:.5pt solid windowtext; 	mso-border-insidev:.5pt solid windowtext; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;I had posted about using SQL Server 2005 DMV in the &lt;a href="http://sqlserverimpressions.blogspot.com/2008/04/checking-fragmentation-in-sql-server.html"&gt;past&lt;/a&gt;. I had been thinking about adding some more details for a long time. Finally here it is..&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;When the data in the underlying tables change, indexes become fragmented (ie. logical ordering of index does not match with the physical ordering of the underlying table). When indexes get fragmented, the performance of the queries will suffer.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;So most of the DBAs add to rebuild/reorganize the indexes in their maintenance jobs.&lt;span style=""&gt;  &lt;/span&gt;Here are the differences between reorganizing and rebuilding the indexes.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoTableGrid" style="border: medium none ; width: 299.3pt; border-collapse: collapse;" width="488" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style="height: 32.25pt;"&gt;   &lt;td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 100.2pt; height: 32.25pt;" valign="top" width="134"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Reorganize&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 133.05pt; height: 32.25pt;" valign="top" width="177"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Rebuild&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 133.05pt; height: 32.25pt;" valign="top" width="177"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Rebuild online in SQL Server 2005&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style="height: 34.25pt;"&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 100.2pt; height: 34.25pt;" valign="top" width="134"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;It causes the data in the outermost data pages to reorder   and will compact the index&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 133.05pt; height: 34.25pt;" valign="top" width="177"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Drops the desired index and creates a new index.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 133.05pt; height: 34.25pt;" valign="top" width="177"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;The database engine creates a new index and it is needs   additional disk space to accommodate two concurrent indexes. During the   process the new index is a write-only index and modifications to original   index and applied to the new one. Once the process it done, it drops the   original index.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style="height: 34.25pt;"&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 100.2pt; height: 34.25pt;" valign="top" width="134"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Takes less system resouces and it is an online operation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 133.05pt; height: 34.25pt;" valign="top" width="177"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Since the index is removed and recreated, it is an offline   operation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 133.05pt; height: 34.25pt;" valign="top" width="177"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;The database engine will still have the original index   available to the users while it building a new index. It uses Row Versioning to   maintain the transactional consistency and integrity.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;I personally look at the page count along with the avg_fragmentation_in_percent because high fragmentation on big indexes will have higher performance impact.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Even if you rebuild all the indexes, you may notice fragmentation for some tables will remain high. This is because if there are less than 1000 pages affected then the fragmentation will not be affected.&lt;span style=""&gt;  &lt;/span&gt;For smaller tables, SQL server will prefer to use a table scan instead of an index.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Here is the script that I use &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Script to Reorganize/Rebuild indexes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @cmd &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;1000&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @Table &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;255&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @SchemaName &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;255&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @IndexName &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;255&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @AvgFragmentationInPercent &lt;span style="color: blue;"&gt;DECIMAL&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @fillfactor &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @ThresholdLowerLimit &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @ThresholdUpperLimit &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @PageCount &lt;span style="color: blue;"&gt;INT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;/* You can specify your&lt;span style=""&gt;  &lt;/span&gt;value for reorganize and rebuild indexes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;If avg_fragmentation_in_percent &gt;= 5 and &lt;30&gt; 1000 Then Reorganize the Index&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;If avg_fragmentation_in_percent &gt;= 30 AND Page_Count &gt; 1000 Then Rebuild the Index&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;*/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @fillfactor &lt;span style="color: gray;"&gt;=&lt;/span&gt; 90&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: green;"&gt;--you can specify value for fill factor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @ThresholdLowerLimit&lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'5.0'&lt;/span&gt; &lt;span style="color: green;"&gt;-- this value is percentage&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @ThresholdUpperLimit &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'30.0'&lt;/span&gt; &lt;span style="color: green;"&gt;-- this value is percentage&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @PageCount &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1000 &lt;span style="color: green;"&gt;--if pages are less then fragmentation would potentially remain same; This is not a magical cut off point but a start&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;-- ensure the temporary table does not exist &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;IF&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'tempdb..#IndexList'&lt;/span&gt;&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: gray;"&gt;IS&lt;/span&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DROP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; #IndexList&lt;span style="color: gray;"&gt;;&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Select all the indexes that have &gt;= 5% percent fragmentation and PageCount &gt; 1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: fuchsia;"&gt;OBJECT_NAME&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;S&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; [TableName]&lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;schema_name&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;T&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;schema_id&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; [SchemaName]&lt;span style="color: gray;"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: fuchsia;"&gt;OBJECT_NAME&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;S&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;object_id&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; [IndexName]&lt;span style="color: gray;"&gt;,&lt;/span&gt;S&lt;span style="color: gray;"&gt;.&lt;/span&gt;page_count&lt;span style="color: gray;"&gt;,&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;avg_fragmentation_in_percent&lt;span style="color: gray;"&gt;,&lt;/span&gt; 0 &lt;span style="color: blue;"&gt;AS&lt;/span&gt; IsDefraged &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; #IndexList&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;FROM&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;sys.dm_db_index_physical_stats&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;DB_ID&lt;/span&gt;&lt;span style="color: gray;"&gt;(),&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL)&lt;/span&gt; S&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;JOIN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: green;"&gt;sys.tables&lt;/span&gt; T &lt;span style="color: blue;"&gt;WITH&lt;/span&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;nolock&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;OBJECT_ID&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; T&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;OBJECT_ID&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; T&lt;span style="color: gray;"&gt;.&lt;/span&gt;is_ms_shipped &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0 &lt;span style="color: green;"&gt;--We only need user tables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;AND&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;avg_fragmentation_in_percent &lt;span style="color: gray;"&gt;&gt;=&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;DECIMAL&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; @ThresholdLowerLimit&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;AND&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;page_count &lt;span style="color: gray;"&gt;&gt;&lt;/span&gt; @PageCount&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ORDER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;page_count &lt;span style="color: blue;"&gt;DESC&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHILE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; 1 &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; #IndexList &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; IsDefraged &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0 &lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;BEGIN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: blue;"&gt;TOP&lt;/span&gt; 1 @Table &lt;span style="color: gray;"&gt;=&lt;/span&gt; TableName&lt;span style="color: gray;"&gt;,&lt;/span&gt; @AvgFragmentationInPercent &lt;span style="color: gray;"&gt;=&lt;/span&gt; avg_fragmentation_in_percent&lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;@SchemaName &lt;span style="color: gray;"&gt;=&lt;/span&gt; SchemaName&lt;span style="color: gray;"&gt;,&lt;/span&gt; @IndexName &lt;span style="color: gray;"&gt;=&lt;/span&gt; IndexName &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; #IndexList &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; IsDefraged &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: green;"&gt;--Reorganizing the index if avg_fragmentation_in_percent &gt; 5 and &lt; style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;IF&lt;/span&gt;&lt;span style="color: gray;"&gt;((&lt;/span&gt;@AvgFragmentationInPercent &lt;span style="color: gray;"&gt;&gt;=&lt;/span&gt; @ThresholdLowerLimit&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;AND&lt;/span&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;@AvgFragmentationInPercent &lt;span style="color: gray;"&gt;&lt;&lt;/span&gt; @ThresholdUpperLimit&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; @cmd &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'ALTER INDEX '&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; @IndexName &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;' ON ['&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;RTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;LTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;@SchemaName&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'].['&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;RTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;LTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;@Table&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'] REORGANIZE'&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;EXEC&lt;/span&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;@cmd&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: blue;"&gt;PRINT&lt;/span&gt; N&lt;span style="color: red;"&gt;'Reorganize Index completed successfully for ['&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; @Table &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;']'&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color: gray;"&gt;())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;END&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: green;"&gt;--Rebuilding the index if&lt;span style=""&gt;  &lt;/span&gt;avg_fragmentation_in_percent &gt; 30&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;ELSE&lt;/span&gt; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;@AvgFragmentationInPercent &lt;span style="color: gray;"&gt;&gt;=&lt;/span&gt; @ThresholdUpperLimit &lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; @cmd &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'ALTER INDEX '&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; @IndexName &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;' ON ['&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;RTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;LTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;@SchemaName&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'].['&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;RTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;LTRIM&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;@Table&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'] REBUILD WITH (FILLFACTOR = '&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;3&lt;span style="color: gray;"&gt;),&lt;/span&gt;@fillfactor&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;', STATISTICS_NORECOMPUTE = OFF)'&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;EXEC&lt;/span&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;@cmd&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;PRINT&lt;/span&gt; N&lt;span style="color: red;"&gt;'Rebuild Index completed successfully for ['&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; @Table &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;']'&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color: gray;"&gt;())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;END&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: green;"&gt;--Update the temp table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; #IndexList &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; IsDefraged &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; TableName &lt;span style="color: gray;"&gt;=&lt;/span&gt; @Table &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: gray;"&gt;AND&lt;/span&gt; IndexName &lt;span style="color: gray;"&gt;=&lt;/span&gt; @IndexName &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;END&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DROP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; #IndexList&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-1843938805044261039?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/1843938805044261039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=1843938805044261039' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1843938805044261039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1843938805044261039'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/10/when-to-reorganizerebuild-index.html' title='When to Reorganize/Rebuild Index'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-5325116198968764005</id><published>2009-09-30T22:42:00.001-04:00</published><updated>2009-10-02T10:46:29.443-04:00</updated><title type='text'>Get the id of the newly inserted row</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:1121917897; 	mso-list-type:hybrid; 	mso-list-template-ids:1475355574 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;There are&lt;span style=""&gt;  &lt;/span&gt;times when we need to retrieve the last inserted identity of a row. Here is a scenario&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in; color: rgb(0, 0, 0);" start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;You need to insert a record into a table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;You need the Id of the row you inserted, so you can use it to insert      rows into tables referencing the first row&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;SQL Server has the options:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: fuchsia;"&gt;SCOPE_IDENTITY&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;()&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: black;"&gt;– Gives the last identity value that was generated in the current scope. In other words, it will give the last identity value that you have explicitly created.&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(51, 51, 51);"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(51, 51, 51);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(51, 51, 51);"&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: fuchsia;"&gt;@@Identity&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: black;"&gt;–Gives the last identity value that was generated in the current session but in any scope.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: fuchsia;"&gt;IDENT_CURRENT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;’tablename’&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;/span&gt;&lt;strong&gt;&lt;span style="font-size: 11pt; font-family: Georgia; font-weight: normal;" lang="EN"&gt;– Gives the last identity value produced in the table regardless if the connection it the scope.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size: 11pt; font-family: Georgia; font-weight: normal;" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;In our scenario, SCOPE_IDENTITY() works perfect to return the identity of the recently added row.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-5325116198968764005?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/5325116198968764005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=5325116198968764005' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5325116198968764005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5325116198968764005'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/09/get-id-of-newly-inserted-row.html' title='Get the id of the newly inserted row'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-6533979373843001850</id><published>2009-06-16T22:07:00.001-04:00</published><updated>2009-06-17T11:12:00.175-04:00</updated><title type='text'>SQL Server 2008 Resource Governor</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:1896353847; 	mso-list-type:hybrid; 	mso-list-template-ids:1008117774 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Resource Govenor enables to manage SQL Server workload and resource utilization.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Terminology:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Resource Pool – It is a collection of physical resources.&lt;span style=""&gt;  &lt;/span&gt;SQL Server 2008 has two built in pools, default and internal. It allows to create maximum of 18 user defined pools.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Workload Group – &lt;span style=""&gt; &lt;/span&gt;It is a container for the requests that are similar to the classification criteria applied to each request. Like Resource pools there are two built in workload groups, default and internal.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Classifier Function – It is a user written criteria that is being applied to the requests.Each user session would be assigned to a particular workgroup load using the classifier function.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Limitations:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in;" start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Limited to only CPU bandwidth and memory management&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;We can only control resource utlization for database engine. It      cannot be used with SSIS, Analysis or Reporting services&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Only one instance of SQL Server can be managed&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Here is just an example of creating resource pool and workload group&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Enable Resource Governor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ALTER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;RESOURCE&lt;/span&gt; &lt;span style="color: blue;"&gt;GOVERNOR&lt;/span&gt; &lt;span style="color: blue;"&gt;RECONFIGURE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;USE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; [master]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;-- Create resource pool to be used&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;RESOURCE&lt;/span&gt; &lt;span style="color: blue;"&gt;POOL&lt;/span&gt; poolAdhoc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: green;"&gt;-- allocate at least &lt;min_cpu_percent,&gt;% of the CPU bandwidth for admin queries&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;MIN_CPU_PERCENT &lt;span style="color: gray;"&gt;=&lt;/span&gt; 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: green;"&gt;-- do not let them exceed &lt;max_cpu_percent,&gt;% either&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; MAX_CPU_PERCENT &lt;span style="color: gray;"&gt;=&lt;/span&gt; 20&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: green;"&gt;-- admin queries should be small and we will allocate about &lt;min_memory_percent,&gt;%&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: green;"&gt;-- of the server memory for them&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; MIN_MEMORY_PERCENT &lt;span style="color: gray;"&gt;=&lt;/span&gt; 5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; MAX_MEMORY_PERCENT &lt;span style="color: gray;"&gt;=&lt;/span&gt; 5 &lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;-- Create adhoc workload group&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;WORKLOAD&lt;/span&gt; &lt;span style="color: blue;"&gt;GROUP&lt;/span&gt; groupAdhoc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: green;"&gt;-- use all defaults&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;IMPORTANCE &lt;span style="color: gray;"&gt;=&lt;/span&gt; MEDIUM&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; REQUEST_MAX_MEMORY_GRANT_PERCENT &lt;span style="color: gray;"&gt;=&lt;/span&gt;25&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; REQUEST_MEMORY_GRANT_TIMEOUT_SEC &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; REQUEST_MAX_CPU_TIME_SEC &lt;span style="color: gray;"&gt;=&lt;/span&gt; 50&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; MAX_DOP &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; GROUP_MAX_REQUESTS &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;USING&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;poolAdhoc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;-- Create admin workload group&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;WORKLOAD&lt;/span&gt; &lt;span style="color: blue;"&gt;GROUP&lt;/span&gt; groupAdmin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: green;"&gt;-- use all defaults&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;IMPORTANCE &lt;span style="color: gray;"&gt;=&lt;/span&gt; MEDIUM&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; REQUEST_MAX_MEMORY_GRANT_PERCENT &lt;span style="color: gray;"&gt;=&lt;/span&gt;25&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; REQUEST_MEMORY_GRANT_TIMEOUT_SEC &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; REQUEST_MAX_CPU_TIME_SEC &lt;span style="color: gray;"&gt;=&lt;/span&gt; 30&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; MAX_DOP &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; GROUP_MAX_REQUESTS &lt;span style="color: gray;"&gt;=&lt;/span&gt; 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;USING&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;poolAdhoc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;FUNCTION&lt;/span&gt; [dbo]&lt;span style="color: gray;"&gt;.&lt;/span&gt;[rgClassifier_Adhoc]&lt;span style="color: gray;"&gt;()&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;RETURNS&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;sysname&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;SCHEMABINDING&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;AS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: green;"&gt;-- Define the return sysname variable for the function&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: blue;"&gt;DECLARE&lt;/span&gt; @grp_name &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;sysname&lt;/span&gt;&lt;span style="color: gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; @grp_name &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'default'&lt;/span&gt;&lt;span style="color: gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: green;"&gt;-- Specify the T-SQL statements for mapping session information&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: green;"&gt;-- with Workload Groups defined for the Resource Governor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: blue;"&gt;IF &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;IS_SRVROLEMEMBER&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'sysadmin'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; @grp_name &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'groupAdmin'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: blue;"&gt;IF &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;APP_NAME&lt;/span&gt;&lt;span style="color: gray;"&gt;()&lt;/span&gt; &lt;span style="color: gray;"&gt;LIKE&lt;/span&gt; &lt;span style="color: red;"&gt;'%Management Studio%'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; @grp_name &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'groupAdhoc'&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: blue;"&gt;RETURN&lt;/span&gt; @grp_name&lt;span style="color: gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;-- Set the classifier function for Resource Governor&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ALTER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;RESOURCE&lt;/span&gt; &lt;span style="color: blue;"&gt;GOVERNOR&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;CLASSIFIER_FUNCTION &lt;span style="color: gray;"&gt;=&lt;/span&gt; dbo&lt;span style="color: gray;"&gt;.&lt;/span&gt;[rgClassifier_Adhoc]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;-- Make changes effective&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ALTER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;RESOURCE&lt;/span&gt; &lt;span style="color: blue;"&gt;GOVERNOR&lt;/span&gt; &lt;span style="color: blue;"&gt;RECONFIGURE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-6533979373843001850?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/6533979373843001850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=6533979373843001850' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6533979373843001850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6533979373843001850'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/06/sql-server-2008-resource-governor.html' title='SQL Server 2008 Resource Governor'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-6466004560144234857</id><published>2009-06-05T20:14:00.002-04:00</published><updated>2009-06-15T15:16:14.802-04:00</updated><title type='text'>SQL Server 2008 – Where is Activity Monitor?</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;For a minute I thought they deprecated the feature. I use it a lot to check the activity going on the databases. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;They moved it to the launch point and the new one  is really cool. Here is a blog with screenshots.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a style="font-family: georgia;" href="http://blogs.msdn.com/dtjones/archive/2008/07/10/where-the-heck-is-activity-monitor.aspx"&gt;http://blogs.msdn.com/dtjones/archive/2008/07/10/where-the-heck-is-activity-monitor.aspx&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-6466004560144234857?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/6466004560144234857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=6466004560144234857' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6466004560144234857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6466004560144234857'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/06/sql-server-2008-where-is-activity.html' title='SQL Server 2008 – Where is Activity Monitor?'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-4853543495516108038</id><published>2009-05-30T20:07:00.001-04:00</published><updated>2009-06-01T13:45:49.835-04:00</updated><title type='text'>SQL Server 2005 Pivots with Dynamic columns</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;a href="http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx"&gt;http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-4853543495516108038?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/4853543495516108038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=4853543495516108038' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4853543495516108038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4853543495516108038'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/05/sql-server-2005-pivots-with-dynamic.html' title='SQL Server 2005 Pivots with Dynamic columns'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-212092730644085535</id><published>2009-05-30T19:28:00.001-04:00</published><updated>2009-06-01T13:43:14.506-04:00</updated><title type='text'>Report Development - Report Requirements Document</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Wingdings; 	panose-1:5 0 0 0 0 0 0 0 0 0; 	mso-font-charset:2; 	mso-generic-font-family:auto; 	mso-font-pitch:variable; 	mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:568003548; 	mso-list-type:hybrid; 	mso-list-template-ids:208941270 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l0:level1 	{mso-level-number-format:bullet; 	mso-level-text:; 	mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in; 	font-family:Symbol;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;        &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;The purpose of report requirements document is to define the requirements for each report or group of reports.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;Personally I don’t like to read 80 pages of technical documentation for a report. Nor would I want to scratch my head wondering what the report is doing Vs what it is supposed to do.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;Here is a quick checklist of items to include in the report requirements documentation&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul style="margin-top: 0in;" type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Business need for the report&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Requirements from the point      of view of the end users &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;The selection and the filter      criteria&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Data elements in the report&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Calculations if any&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Parameters in the report&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Sort, grouping and totaling      requirements&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Appearance and style      requirements (i.e. layout of the report, column names to be shown etc)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Performance requirements&lt;span style=""&gt;  &lt;/span&gt;(speed and latency)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Security requirements (who      needs access to the report)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-212092730644085535?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/212092730644085535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=212092730644085535' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/212092730644085535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/212092730644085535'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/05/report-development-report-requirements.html' title='Report Development - Report Requirements Document'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-5095090966991532440</id><published>2009-05-23T06:04:00.002-04:00</published><updated>2009-06-01T13:40:22.365-04:00</updated><title type='text'>Microsoft Chart Controls</title><content type='html'>&lt;span style="font-family: georgia;font-family:georgia;font-size:100%;"  &gt;Great blog about ASP.net charting control&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a style="font-family: georgia;" href="http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-5095090966991532440?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/5095090966991532440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=5095090966991532440' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5095090966991532440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5095090966991532440'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/05/microsoft-chart-controls.html' title='Microsoft Chart Controls'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-7908658374716912836</id><published>2009-05-13T22:03:00.001-04:00</published><updated>2009-05-15T15:05:03.476-04:00</updated><title type='text'>Bad Data Models</title><content type='html'>&lt;span style="font-family: georgia;font-size:100%;" &gt;We all know what a good data model is and spend significant time designing a good data model. So if there are good data models then there are bad data models too.&lt;br /&gt;&lt;br /&gt;There is a difference between incorrect data models and bad data models. An incorrect data model would not satisfy business requirements and hence they don't make to the implementation. But bad data models would get implemented. They do more harm to the system. Every part of the application has to compensate for the bad data model.&lt;br /&gt;&lt;br /&gt;Bad data models evolve due to various reasons – time and resource constraints, inexperience, over engineered modeling and sometimes sloppiness.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-7908658374716912836?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/7908658374716912836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=7908658374716912836' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7908658374716912836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7908658374716912836'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/05/bad-data-models.html' title='Bad Data Models'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-10561981307103760</id><published>2009-05-07T19:17:00.000-04:00</published><updated>2009-05-08T13:47:37.522-04:00</updated><title type='text'>SQL Server 2008 – Maximum Capacity Specs</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;I found this article which gives the maximum size specifications for SQL Server 2008&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms143432.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms143432.aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-10561981307103760?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/10561981307103760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=10561981307103760' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/10561981307103760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/10561981307103760'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/05/sql-server-2008-maximum-capacity-specs.html' title='SQL Server 2008 – Maximum Capacity Specs'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-888628759115220184</id><published>2009-05-07T19:15:00.000-04:00</published><updated>2009-05-08T13:36:11.896-04:00</updated><title type='text'>SQL Server 2008 Min and Max Date Ranges</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Here are the Minimum and Maximum date ranges&lt;/span&gt;&lt;span style="font-size: 11pt;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;SQL Server 2005&lt;br /&gt;Min Date: 1753-01-01 00:00:00.000&lt;br /&gt;Max Date: 9999-12-31 23:59:59.999&lt;br /&gt;&lt;br /&gt;SQL Server 2008&lt;br /&gt;Min Date: 0001-01-01 00:00:00.000&lt;br /&gt;Max Date: 9999-12-31 23:59:59.999&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-888628759115220184?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/888628759115220184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=888628759115220184' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/888628759115220184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/888628759115220184'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/05/sql-server-2008-min-and-max-date-ranges.html' title='SQL Server 2008 Min and Max Date Ranges'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-7821638573061323864</id><published>2009-03-27T18:06:00.001-04:00</published><updated>2009-04-07T13:21:17.167-04:00</updated><title type='text'>Reporting services 2008 does not need IIS</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;Here is how it handles without IIS&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: georgia;" href="http://blogs.msdn.com/bwelcker/archive/2007/12/04/everybody-why-leave-iis.aspx"&gt;http://blogs.msdn.com/bwelcker/archive/2007/12/04/everybody-why-leave-iis.aspx&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-7821638573061323864?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/7821638573061323864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=7821638573061323864' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7821638573061323864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7821638573061323864'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/03/reporting-services-2008-does-not-need.html' title='Reporting services 2008 does not need IIS'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-8698124450273958098</id><published>2009-02-12T21:58:00.001-05:00</published><updated>2009-04-07T13:21:52.578-04:00</updated><title type='text'>SSIS Configurations</title><content type='html'>&lt;span style="font-family: georgia;font-family:georgia;font-size:100%;"  &gt;There is a significant change in how SSIS applies configurations in SQL Server 2008. The configurations are applied twice – once before applying the command line options and once after applying the command line options. So it overwrites the value specified on the command line.&lt;br /&gt;&lt;br /&gt;This is a nice improvement since you can set up a package with SQL Server Configurations and change the connection string for SQL Server configuration.&lt;br /&gt;&lt;br /&gt;Check this link for more information&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; font-family: georgia;font-size:100%;" &gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link style="font-family: georgia;" rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="font-family: georgia;"&gt;&lt;span style=";font-size:100%;" &gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc671625.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc671625.aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="font-family: georgia;"&gt;&lt;span style=";font-size:100%;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="font-family: georgia;"&gt;&lt;span style=";font-size:100%;" &gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-8698124450273958098?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/8698124450273958098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=8698124450273958098' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/8698124450273958098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/8698124450273958098'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/02/ssis-configurations.html' title='SSIS Configurations'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-5516879069711624063</id><published>2009-02-01T06:31:00.000-05:00</published><updated>2009-02-06T15:01:34.365-05:00</updated><title type='text'>Truncate Mirrored Database Log File</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:1799372295; 	mso-list-type:hybrid; 	mso-list-template-ids:1947355734 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l0:level2 	{mso-level-number-format:alpha-lower; 	mso-level-tab-stop:1.0in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style="line-height: 12pt;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(51, 51, 51);"&gt;If you are running asynchronous database mirroring, then there could be a backlog of transaction log records that have not been sent from the principal to the mirror (called the database mirroring SEND queue). The transaction log records cannot be freed until they have been successfully sent. With a high rate of transaction log record generation and limited bandwidth on the network (or other hardware issues), the backlog can grow quite large and cause the transaction log to grow.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="line-height: 12pt;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="line-height: 12pt;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(51, 51, 51);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height: 12pt;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(51, 51, 51);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;On the mirrored database, you cannot backup the log file with TRUNCATE_ONLY. Here the steps to shrink the log file for a database participating in mirroring&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in;" start="1" type="1"&gt;&lt;li class="MsoNormal" style="color: rgb(8, 8, 8);"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Backup the log file to a location&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;BACKUP&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt; &lt;span style="color: fuchsia;"&gt;Log&lt;/span&gt; YourDatabaseName &lt;span style="color: blue;"&gt;TO&lt;/span&gt; &lt;span style="color: blue;"&gt;DISK&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'D:\BACKUP\DBNAME_20090201.TRN'&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;span style="color: red;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in; color: rgb(0, 0, 0);" start="2" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Check if there is      enough free space on perform the shrink operation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in; color: rgb(0, 0, 0);"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt; &lt;span style="color: blue;"&gt;name&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: blue;"&gt;size&lt;/span&gt;&lt;span style="color: gray;"&gt;/&lt;/span&gt;128.0 &lt;span style="color: gray;"&gt;-&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CAST&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;FILEPROPERTY&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;name&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'SpaceUsed'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;)/&lt;/span&gt;128.0 &lt;span style="color: blue;"&gt;AS&lt;/span&gt; AvailableSpaceInMB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;FROM&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt; &lt;span style="color: green;"&gt;sys.database_files&lt;/span&gt;&lt;span style="color: gray;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;DBCC&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt; SQLPERF&lt;span style="color: gray;"&gt;(&lt;/span&gt;LOGSPACE&lt;span style="color: gray;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;If there is no sufficient free space then the shrink operation cannot reduce file size.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in;" start="3" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Check if all the      transactions are written into the disk&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;DBCC&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt; LOGINFO&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'YourDatabaseName'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;The status of the last transaction should be 0. If not, then backup the transaction log once again.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in; color: rgb(0, 0, 0);" start="4" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Shrink the log file&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal" style="margin-left: 0.25in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.25in; text-indent: 0.25in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;DBCC&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt; SHRINKFILE&lt;span style="color: gray;"&gt;(&lt;/span&gt;logfilename &lt;span style="color: gray;"&gt;,&lt;/span&gt; target_size&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left: 0.25in; text-indent: 0.25in;"&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.25in; text-indent: 0.25in;"&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;If the transaction lof file does not shrink after performing the above steps then backup the log file again to make more of the virtual log files inactive.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;Also check the column &lt;/span&gt;&lt;strong&gt;&lt;span style="font-size: 9.5pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;LOG_REUSE_WAIT_DESC&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 9.5pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt; in the &lt;b&gt;sys.databases&lt;/b&gt; catalog view to check if the reuse of the transaction log space is waiting on anything.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 9.5pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9.5pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9.5pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;Check this link to find the factors that can delay log truncation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 9.5pt; font-family: Georgia; color: rgb(8, 8, 8);"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia; color: blue;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms345414%28SQL.90%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms345414(SQL.90).aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-5516879069711624063?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/5516879069711624063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=5516879069711624063' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5516879069711624063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5516879069711624063'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/02/truncate-mirrored-database-log-file.html' title='Truncate Mirrored Database Log File'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-2218588676526189302</id><published>2009-01-27T21:50:00.003-05:00</published><updated>2009-02-06T15:04:06.162-05:00</updated><title type='text'>Connecting to Remote SSIS Server</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;}  /* List Definitions */  @list l0 	{mso-list-id:856429328; 	mso-list-type:hybrid; 	mso-list-template-ids:-1729737532 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 	{mso-level-tab-stop:.5in; 	mso-level-number-position:left; 	text-indent:-.25in;} @list l0:level2 	{mso-level-number-format:alpha-lower; 	mso-level-tab-stop:1.0in; 	mso-level-number-position:left; 	text-indent:-.25in;} ol 	{margin-bottom:0in;} ul 	{margin-bottom:0in;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;If you get the “Access is denied” error while connecting to remote SSIS server, you may have to perform the steps outlined in the following link&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa337083.aspx"&gt;http://msdn.microsoft.com/en-us/library/aa337083.aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;Additional steps to perform which are not in the MSDN page &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.25in;"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in;" start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;Add      the user to the Distributed COM Users group on the server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;Restart      the SSIS service after making changes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;At      the minimum, add the user to the MSDB db_dtsltduser role to edit their own      packages. Check this link for more permissions on the msdb database&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal" style="margin-left: 0.25in;"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-size: 10pt; font-family: Georgia;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms141053.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms141053.aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-2218588676526189302?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/2218588676526189302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=2218588676526189302' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/2218588676526189302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/2218588676526189302'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/01/connecting-to-remote-ssis-server.html' title='Connecting to Remote SSIS Server'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-7722179386479096067</id><published>2009-01-27T21:48:00.000-05:00</published><updated>2009-01-27T21:48:01.565-05:00</updated><title type='text'>SSIS 2008 New Features</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p style="font-family: times new roman;" class="MsoNormal"&gt;This is a neat article which outlines the new SSIS features in SQL Server 2008&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.simple-talk.com/content/print.aspx?article=541"&gt;http://www.simple-talk.com/content/print.aspx?article=541&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-7722179386479096067?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/7722179386479096067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=7722179386479096067' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7722179386479096067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7722179386479096067'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/01/ssis-2008-new-features.html' title='SSIS 2008 New Features'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-151034356660902505</id><published>2009-01-13T20:21:00.003-05:00</published><updated>2009-01-27T10:48:29.776-05:00</updated><title type='text'>SQL Server 2008 Top 10 T-SQL features</title><content type='html'>&lt;span style=";font-family:times new roman;font-size:130%;"  &gt;Here is the list of new T-SQL features that I really like in SQL Server2K8.&lt;br /&gt;&lt;br /&gt;1.Intellisense in SQL Server Management Studio – It is easy to learn the database schema and the objects on the fly with this feature&lt;br /&gt;&lt;br /&gt;2.Inline Variable Assignment – Inline variable initialization is possible now&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;VALUE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;GO&lt;/span&gt;&lt;/p&gt;  &lt;span style=";font-family:times new roman;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;3.Compound Assigment of variables&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: gray;"&gt;+=&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;GO&lt;/span&gt;&lt;/p&gt;  &lt;span style=";font-family:times new roman;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4.Filtered Indexes - Filtered index is used to index a portion of rows in a table. It is an optimized nonclustered index which can improve query performance and reduce index cost.&lt;br /&gt;&lt;br /&gt;5.Table Valued Parameters – These are new parameter types in SQL Server 2008 which allows to send mulitple rows of data to a T-SQL statement or routine.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6.Row Constructors – These allow to insert multiple rows with a single INSERT statement&lt;br /&gt;&lt;br /&gt;7.Merge statement – It is a new DML statement which allows to perform Insert/Update/Delete operations on one table using single scan.&lt;br /&gt;&lt;br /&gt;8.New datatypes – SQL 2K8 has various new datatypes like spatial datatypes, datetime datatypes (DATE, TIME, DATETIME2) and Hierarchy datatypes. Of all FileStream Data type interests me the most (we don’t have to be creative inventing ways to store unstructured data anymore).&lt;br /&gt;&lt;br /&gt;9.Grouping sets – This clause allows us to easily specify combinations of groupings to see different levels of aggregated data.&lt;br /&gt;&lt;br /&gt;10.Sparse Columns – Columns created with this clause takes less space than the regular columns when it contains zero or null. These also allow us to create tables with more than 1024 columns.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-151034356660902505?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/151034356660902505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=151034356660902505' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/151034356660902505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/151034356660902505'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/01/sql-server-2008-top-10-t-sql-features.html' title='SQL Server 2008 Top 10 T-SQL features'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-6690866955607266229</id><published>2009-01-11T06:24:00.002-05:00</published><updated>2009-01-13T16:27:17.525-05:00</updated><title type='text'>SQL Server 2008 – What happened to Surface Area Configuration tool?</title><content type='html'>&lt;span style="font-family:times new roman;"&gt;Have you ever wondered what happened to the Surface Area Configuration (SAC) tool in SQL Server 2008? It has been removed in SQL Server 2008. SQL Configuration Manager or SSMS can be used to configure settings, options and component features.&lt;br /&gt;&lt;br /&gt;Here is an article from BOL&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc281850.aspx"&gt;&lt;span style="font-family:times new roman;"&gt;http://msdn.microsoft.com/en-us/library/cc281850.aspx&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-6690866955607266229?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/6690866955607266229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=6690866955607266229' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6690866955607266229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6690866955607266229'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2009/01/sql-server-2008-what-happened-to.html' title='SQL Server 2008 – What happened to Surface Area Configuration tool?'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-5593631790981020508</id><published>2008-12-27T15:52:00.000-05:00</published><updated>2008-12-29T15:53:26.078-05:00</updated><title type='text'>SQL Server 2008 Merge Statement Error</title><content type='html'>If multiple rows match in the target for the criteria then MERGE statement will throw the following error&lt;br /&gt;&lt;br /&gt;Msg 8672, Level 16, State 1, Line 1&lt;br /&gt;The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times.&lt;br /&gt;&lt;br /&gt;MERGE statement is deterministic whereas update with join will update any row without error. You can use one of the following options to fix the error&lt;br /&gt;&lt;br /&gt;1.Make sure that the target row matches at most one source row &lt;br /&gt;2.Use a GROUP BY to group the source rows.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-5593631790981020508?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/5593631790981020508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=5593631790981020508' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5593631790981020508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5593631790981020508'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/12/sql-server-2008-merge-statement-error.html' title='SQL Server 2008 Merge Statement Error'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-4208735646402304569</id><published>2008-12-06T07:22:00.000-05:00</published><updated>2008-12-06T07:22:00.500-05:00</updated><title type='text'>In-line variable Initialization and Compound Assignment</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} p 	{margin-top:0in; 	margin-right:0in; 	margin-bottom:7.5pt; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;SQL Server 2008 supports in-line variable initialization and compound assignment, a feature which developers have been enjoying for years. This feature saves lot of code and it makes it more readable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;In line Variable Assignment&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--SQL Server 2005&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;INT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;AS&lt;/span&gt; VALUE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--SQL Server 2008&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;AS&lt;/span&gt; VALUE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;Compound Assignment:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Simple variable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: gray;"&gt;+=&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--DML Statements&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Create table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; Color&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;ID &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; ColorName &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Populate Staging table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; Color &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Red'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;2&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Blue'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;3&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Green'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ColorName &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Color &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1 &lt;span style="color: green;"&gt;--returns Red&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;UPDATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; Color &lt;span style="color: blue;"&gt;SET&lt;/span&gt; ColorName &lt;span style="color: gray;"&gt;+=&lt;/span&gt; &lt;span style="color: red;"&gt;'-B'&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ColorName &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Color &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1 &lt;span style="color: green;"&gt;--returns Red-B&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-4208735646402304569?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/4208735646402304569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=4208735646402304569' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4208735646402304569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4208735646402304569'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/12/in-line-variable-initialization-and.html' title='In-line variable Initialization and Compound Assignment'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-1038571472285457730</id><published>2008-12-06T06:06:00.001-05:00</published><updated>2008-12-06T06:06:01.182-05:00</updated><title type='text'>SQL Server 2008 Data Compression</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} p 	{margin-top:0in; 	margin-right:0in; 	margin-bottom:7.5pt; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} p 	{margin-top:0in; 	margin-right:0in; 	margin-bottom:7.5pt; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;SQL Server 2008 offers two different forms of data compression – Row and Page level compression.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;b style=""&gt;&lt;span style="color: black;"&gt;Row Compression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;Row level compression does not apply any algorithm to compress the data. It changes the physical storage format which is efficient in storing the numeric and fixed length character data types. It minimizes the metadata (column information, length, offset etc) associated with a row. No application changes are required when tables are enabled for compression.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;Here is an example &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Create a table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; TestData&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;ID &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt;DataValue &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;50&lt;span style="color: gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Insert data into the table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DECLARE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: blue;"&gt;INT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHILE &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;@i &lt;span style="color: gray;"&gt;&lt;=&lt;/span&gt; 100000&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; TestData &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;@i&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'value:'&lt;/span&gt; &lt;span style="color: gray;"&gt;+&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;cast&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;@i &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;)))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; @i &lt;span style="color: gray;"&gt;=&lt;/span&gt; @i &lt;span style="color: gray;"&gt;+&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Check for the savings if row level compression is enabled&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;sp_estimate_data_compression_savings &lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;'TestData'&lt;/span&gt;&lt;span style="color: gray;"&gt;,NULL,NULL,&lt;/span&gt;&lt;span style="color: red;"&gt;'Row'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Alter the table to apply row level compression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ALTER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; TestData &lt;span style="color: blue;"&gt;REBUILD&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;DATA_COMPRESSION &lt;span style="color: gray;"&gt;=&lt;/span&gt; ROW&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="font-size: 10pt; line-height: 140%; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;b style=""&gt;&lt;span style="color: black;"&gt;Page Compression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;This shares the common data between rows in a given page.&lt;span style=""&gt;  &lt;/span&gt;It uses the both Row Compression and Prefix Compression.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;Prefix Compression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;For every column the duplicate prefixes are saved in the compressed information headers (CI) which reside after the page header. A reference number is assigned to the prefix and it is replaced on where the prefixes are used.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;Dictionary Compression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;All the duplicate values in the entire page are stored on the CI. Prefix compression is applicable to columns where as dictionary compression is applicable to the entire page.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Check the savings is Page level compression is enabled&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;sp_estimate_data_compression_savings &lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;'TestData'&lt;/span&gt;&lt;span style="color: gray;"&gt;,NULL,NULL,&lt;/span&gt;&lt;span style="color: red;"&gt;'Page'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Alter the table to apply page level compression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ALTER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; TestData &lt;span style="color: blue;"&gt;REBUILD&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;DATA_COMPRESSION &lt;span style="color: gray;"&gt;=&lt;/span&gt; Page&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;Compressing a table is a CPU intensive operation. There is an optional parameter called maxdop which can be used to specify the max number of processors we want the rebuild to use.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Alter the table to apply page level compression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ALTER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; TestData &lt;span style="color: blue;"&gt;REBUILD&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;DATA_COMPRESSION &lt;span style="color: gray;"&gt;=&lt;/span&gt; Page&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;MAXDOP&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; 4&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;For more information here&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style=""&gt;&lt;a href="http://blogs.msdn.com/sqlserverstorageengine/archive/2007/11/12/types-of-data-compression-in-sql-server-2008.aspx"&gt;http://blogs.msdn.com/sqlserverstorageengine/archive/2007/11/12/types-of-data-compression-in-sql-server-2008.aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style=""&gt;This article explains the compression ratios with real world databases&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style="font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;a href="http://sqlblog.com/blogs/linchi_shea/archive/2008/05/11/sql-server-2008-page-compression-compression-ratios-from-real-world-databases.aspx"&gt;http://sqlblog.com/blogs/linchi_shea/archive/2008/05/11/sql-server-2008-page-compression-compression-ratios-from-real-world-databases.aspx&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-1038571472285457730?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/1038571472285457730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=1038571472285457730' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1038571472285457730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1038571472285457730'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/12/sql-server-2008-data-compression.html' title='SQL Server 2008 Data Compression'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-1908428007204945418</id><published>2008-12-02T20:23:00.001-05:00</published><updated>2008-12-02T20:23:00.923-05:00</updated><title type='text'>SQL Server 2008 –  Backup Compression feature</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} p 	{margin-top:0in; 	margin-right:0in; 	margin-bottom:7.5pt; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;To compress a backup specify COMPRESSION in the WITH clause of the backup command.&lt;/span&gt;&lt;/p&gt;&lt;p style="line-height: 140%; vertical-align: top;"&gt;Here is an example:&lt;br /&gt;&lt;span style="color: black;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;BACKUP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt; YourDatabaseName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;TO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;DISK&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'C:\YourDatabaseName.bak'&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WITH&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INIT&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;COMPRESSION&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;Compressing a backup typically needs less I/O, because it is smaller so it increases the speed of the backup. But compression process consumes CPU usage.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;By default backup compression is off.&lt;span style=""&gt;  &lt;/span&gt;To enable it we can use the ‘backup compression default’ configuration.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;Use&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;master&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;Exec&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: maroon;"&gt;sp_configure&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;'backup compression default'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'1'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;RECONFIGURE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style="font-size: 12pt; font-family: &amp;quot;Times New Roman&amp;quot;; color: black;"&gt;You don’t have to specify anything to restore the compressed backup&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-1908428007204945418?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/1908428007204945418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=1908428007204945418' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1908428007204945418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1908428007204945418'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/12/sql-server-2008-backup-compression.html' title='SQL Server 2008 –  Backup Compression feature'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-8005220327657914085</id><published>2008-12-01T19:19:00.001-05:00</published><updated>2008-12-02T16:20:39.486-05:00</updated><title type='text'>SQL Server 2008 -  Row Constructors</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} p 	{margin-top:0in; 	margin-right:0in; 	margin-bottom:7.5pt; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;There are times when we need to insert multiple rows into a table. SQL Server 2008 has row constructors which simplifies the data insertion process. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="line-height: 140%; vertical-align: top;"&gt;&lt;span style="color: black;"&gt;Here are the various ways we can insert multiple rows with a single INSERT statement &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Create a table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;ID &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; name &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;-- Insert with VALUE clause &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable &lt;span style="color: blue;"&gt;Values &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;'Mary'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable &lt;span style="color: blue;"&gt;Values &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;2&lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: red;"&gt;'Jim'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Insert with Select clause&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; 3&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Hillary'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; 4&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Lisa'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Insert with &lt;st1:place st="on"&gt;UNION&lt;/st1:place&gt; ALL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; 5&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Rick'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;UNION&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;ALL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; 6&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'John'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;UNION&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;ALL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; 7&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Tom'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Insert with Row Constructors (new in SQL Server 2008)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;VALUES&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;8&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Toni'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;9&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Joe'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;10&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'dave'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-8005220327657914085?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/8005220327657914085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=8005220327657914085' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/8005220327657914085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/8005220327657914085'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/12/sql-server-2008-row-constructors.html' title='SQL Server 2008 -  Row Constructors'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-1248287193417999641</id><published>2008-11-27T10:18:00.000-05:00</published><updated>2008-11-27T10:18:01.006-05:00</updated><title type='text'>SQL Server 2008 MERGE </title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;MERGE statement performs insert,update or delete operations on target table based on the results of a join with source table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;br /&gt;&lt;br /&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;Here is a simple example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Staging table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; Staging&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;ID &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Real table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;ID &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Populate Staging table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; Staging &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Red'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;2&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Blue'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;3&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Green'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Merge statement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;MERGE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; RealTable RT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;USING&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Staging&lt;span style="color: gray;"&gt;)&lt;/span&gt; S&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ON &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: green;"&gt;--update rows when matched&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;TARGET&lt;/span&gt; &lt;span style="color: green;"&gt;--insert if rows donot exist in the target table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: gray;"&gt;SOURCE&lt;/span&gt; &lt;span style="color: green;"&gt;--delete if rows donot exist in the source table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: blue;"&gt;DELETE&lt;/span&gt;&lt;span style="color: gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Test the update&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;UPDATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; Staging &lt;span style="color: blue;"&gt;SET&lt;/span&gt; Color &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Pink'&lt;/span&gt; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;MERGE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; RealTable RT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;USING&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Staging&lt;span style="color: gray;"&gt;)&lt;/span&gt; S&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ON &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: green;"&gt;--update rows when matched&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;TARGET&lt;/span&gt; &lt;span style="color: green;"&gt;--insert if rows donot exist in the target table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: gray;"&gt;SOURCE&lt;/span&gt; &lt;span style="color: green;"&gt;--delete if rows donot exist in the source table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: blue;"&gt;DELETE&lt;/span&gt;&lt;span style="color: gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Test the delete&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DELETE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Staging &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;MERGE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; RealTable RT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;USING&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Staging&lt;span style="color: gray;"&gt;)&lt;/span&gt; S&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ON &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: green;"&gt;--update rows when matched&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;TARGET&lt;/span&gt; &lt;span style="color: green;"&gt;--insert if rows donot exist in the target table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHEN&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;MATCHED&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: gray;"&gt;SOURCE&lt;/span&gt; &lt;span style="color: green;"&gt;--delete if rows donot exist in the source table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;THEN&lt;/span&gt; &lt;span style="color: blue;"&gt;DELETE&lt;/span&gt;&lt;span style="color: gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DROP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DROP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; Staging&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-1248287193417999641?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/1248287193417999641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=1248287193417999641' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1248287193417999641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1248287193417999641'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/11/sql-server-2008-merge.html' title='SQL Server 2008 MERGE '/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-3673250832389010066</id><published>2008-11-27T09:44:00.000-05:00</published><updated>2008-11-27T09:44:00.314-05:00</updated><title type='text'>UPSERT functionality </title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;It UPDATEs rows if they exist in the selected row set or INSERTs rows if they don’t exist in one Sql command.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;SQL Server 2005 does not have this feature. You will need 2 queries to get the functionality.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"&gt;&lt;/o:smarttagtype&gt;&lt;o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"&gt;&lt;/o:smarttagtype&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if !mso]&gt;&lt;object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"&gt;&lt;/object&gt; &lt;style&gt; st1\:*{behavior:url(#ieooui) } &lt;/style&gt; &lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;Here is a simple example&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Staging table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; Staging&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;ID &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Real table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;(&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;ID &lt;span style="color: blue;"&gt;int&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;10&lt;span style="color: gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Populate Staging table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; Staging &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Red'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;2&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Blue'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;,&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;3&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Green'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--UPSERT Functionality&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Perform UPDATE first&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;UPDATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; RealTable &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; Color &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;FROM&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; RealTable &lt;span style="color: blue;"&gt;AS&lt;/span&gt; RT&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;NOLOCK&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;INNER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;JOIN&lt;/span&gt; Staging S&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;NOLOCK&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Perform INSERT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable&lt;span style="color: gray;"&gt;(&lt;/span&gt;ID&lt;span style="color: gray;"&gt;,&lt;/span&gt;Color&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;st1:place st="on"&gt;&lt;st1:city st="on"&gt;Staging&lt;/st1:city&gt; &lt;st1:state st="on"&gt;&lt;span style="color: blue;"&gt;AS&lt;/span&gt;&lt;/st1:state&gt;&lt;/st1:place&gt; S&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;EXISTS&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; RealTable &lt;span style="color: blue;"&gt;AS&lt;/span&gt; RT &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Test the update&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;UPDATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; Staging &lt;span style="color: blue;"&gt;SET&lt;/span&gt; Color &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Pink'&lt;/span&gt; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;UPDATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; RealTable &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;SET&lt;/span&gt; Color &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;Color&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;FROM&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; RealTable &lt;span style="color: blue;"&gt;AS&lt;/span&gt; RT&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;NOLOCK&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;INNER&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;JOIN&lt;/span&gt; Staging S&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;NOLOCK&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Perform INSERT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;INSERT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; RealTable&lt;span style="color: gray;"&gt;(&lt;/span&gt;ID&lt;span style="color: gray;"&gt;,&lt;/span&gt;Color&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ID&lt;span style="color: gray;"&gt;,&lt;/span&gt; Color &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;st1:place st="on"&gt;&lt;st1:city st="on"&gt;Staging&lt;/st1:city&gt; &lt;st1:state st="on"&gt;&lt;span style="color: blue;"&gt;AS&lt;/span&gt;&lt;/st1:state&gt;&lt;/st1:place&gt; S&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;WHERE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;EXISTS&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; RealTable &lt;span style="color: blue;"&gt;AS&lt;/span&gt; RT &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; RT&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID &lt;span style="color: gray;"&gt;=&lt;/span&gt; S&lt;span style="color: gray;"&gt;.&lt;/span&gt;ID&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DROP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; RealTable&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;DROP&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; Staging&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;br /&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-3673250832389010066?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/3673250832389010066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=3673250832389010066' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3673250832389010066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3673250832389010066'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/11/upsert-functionality.html' title='UPSERT functionality '/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-4329831426097869529</id><published>2008-11-19T00:49:00.000-05:00</published><updated>2008-11-25T12:54:33.806-05:00</updated><title type='text'>SQL Server 2008 - Policy Based Management</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;After lots of confusion between DMF (Dynamic Management Functions) and DMF (Declarative Management Framework), a new name is given to be clear – Microsoft SQL Server 2008 Policy Based Management.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;/p&gt;&lt;p class="MsoNormal"&gt;Policy Based Management allows to define and enforce the polices for configuring and managing SQL Servers across the enterprise. Here is just a brief description of the terminology.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Target – Object to be managed&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Facet – Property of the object(target)&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Condition – list of criteria for target’s facets&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Policy - Set of conditions on the facets of a target&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Evaluation Modes&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;On Demand – policy is evaluated only when manually run by admin&lt;/p&gt;  &lt;p class="MsoNormal"&gt;On change: Prevent – DDL triggers prevent policy violations&lt;/p&gt;  &lt;p class="MsoNormal"&gt;On Change: log only – Event notifications are used to check the policy when changes are made&lt;/p&gt;  &lt;p class="MsoNormal"&gt;On Schedule – SQL Agent job checks the policies for periodical violations&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-4329831426097869529?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/4329831426097869529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=4329831426097869529' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4329831426097869529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4329831426097869529'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/11/sql-server-2008-policy-based-management.html' title='SQL Server 2008 - Policy Based Management'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-6612603329615837792</id><published>2008-10-17T20:52:00.000-04:00</published><updated>2008-11-02T17:52:56.205-05:00</updated><title type='text'>SSIS Data types and expressions</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Here is the link to integration services data types&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms141036.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms141036.aspx&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;Expressions in SSIS:&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;To convert today’s date (getdate()) to string (Format: 2008-05-07)&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: fuchsia;"&gt;SUBSTRING&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: gray;"&gt;((&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;DT_STR&lt;span style="color: gray;"&gt;,&lt;/span&gt; 30&lt;span style="color: gray;"&gt;,&lt;/span&gt; 1252&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color: gray;"&gt;(),&lt;/span&gt; 1&lt;span style="color: gray;"&gt;,&lt;/span&gt; 10 &lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style="color:gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;To convert today’s date (getdate()) to string (format: 20080507)&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:gray;"   &gt;(&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;DT_STR&lt;span style="color:gray;"&gt;,&lt;/span&gt; 4&lt;span style="color:gray;"&gt;,&lt;/span&gt; 1252&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:fuchsia;"&gt;Year&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:gray;"&gt;)+RIGHT(&lt;/span&gt;"0" &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;DT_STR&lt;span style="color:gray;"&gt;,&lt;/span&gt; 2&lt;span style="color:gray;"&gt;,&lt;/span&gt; 1252&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:fuchsia;"&gt;MONTH&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:gray;"&gt;),&lt;/span&gt; 2&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+RIGHT(&lt;/span&gt;"0" &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;DT_STR&lt;span style="color:gray;"&gt;,&lt;/span&gt; 2&lt;span style="color:gray;"&gt;,&lt;/span&gt; 1252&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:fuchsia;"&gt;Day&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:gray;"&gt;),&lt;/span&gt; 2&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style="color:gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;To convert today’s date (getdate()) to int (Format: 20080507)&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;b style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:gray;"   &gt;(&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;DT_I4&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;DT_STR&lt;span style="color:gray;"&gt;,&lt;/span&gt; 4&lt;span style="color:gray;"&gt;,&lt;/span&gt; 1252&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:fuchsia;"&gt;Year&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:gray;"&gt;)+RIGHT(&lt;/span&gt;"0" &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;DT_STR&lt;span style="color:gray;"&gt;,&lt;/span&gt; 2&lt;span style="color:gray;"&gt;,&lt;/span&gt; 1252&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:fuchsia;"&gt;MONTH&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:gray;"&gt;),&lt;/span&gt; 2&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;+RIGHT(&lt;/span&gt;"0" &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;DT_STR&lt;span style="color:gray;"&gt;,&lt;/span&gt; 2&lt;span style="color:gray;"&gt;,&lt;/span&gt; 1252&lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:fuchsia;"&gt;Day&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:gray;"&gt;),&lt;/span&gt; 2&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-6612603329615837792?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/6612603329615837792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=6612603329615837792' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6612603329615837792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6612603329615837792'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/10/ssis-data-types-and-expressions.html' title='SSIS Data types and expressions'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-2234661648097699246</id><published>2008-10-16T23:31:00.000-04:00</published><updated>2008-11-02T17:52:01.698-05:00</updated><title type='text'>Grant permissions to view stored procedure text</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;Sometimes in a production environment you may want to give developers read access to the text of the stored procedures but not be able to modify or execute them. In SQL Server 2005, you can grant VIEW DEFINITION permissions. Here are different ways to it&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;To grant view permissions to the entire schema&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;GRANT&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; &lt;span style="color:blue;"&gt;VIEW&lt;/span&gt; DEFINITION &lt;span style="color:blue;"&gt;ON&lt;/span&gt; &lt;span style="color:blue;"&gt;SCHEMA&lt;/span&gt;&lt;span style="color:gray;"&gt;::&lt;/span&gt;dbo &lt;span style="color:blue;"&gt;TO&lt;/span&gt; [UserName]&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;To grant permissions to specific stored procedure&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;GRANT&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; &lt;span style="color:blue;"&gt;VIEW&lt;/span&gt; DEFINITION &lt;span style="color:blue;"&gt;ON&lt;/span&gt; YourStoredProcedureName &lt;span style="color:blue;"&gt;TO&lt;/span&gt; [UserName]&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;To grant view definition on all the stored procedures in the database&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:green;"   &gt;--temporary table&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;DECLARE&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; @tmpTable &lt;span style="color:blue;"&gt;TABLE&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;PK_ID &lt;span style="color:blue;"&gt;INT&lt;/span&gt; &lt;span style="color:blue;"&gt;IDENTITY&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;1&lt;span style="color:gray;"&gt;,&lt;/span&gt; 1&lt;span style="color:gray;"&gt;)&lt;/span&gt; &lt;span style="color:gray;"&gt;NOT&lt;/span&gt; &lt;span style="color:gray;"&gt;NULL&lt;/span&gt; &lt;span style="color:blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color:blue;"&gt;KEY&lt;/span&gt; &lt;span style="color:blue;"&gt;CLUSTERED&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;[name]&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color:blue;"&gt;SYSNAME&lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:green;"   &gt;--declare variables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;DECLARE&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; @name &lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color:blue;"&gt;SYSNAME&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;@RowCount&lt;span style=""&gt;         &lt;/span&gt;&lt;span style="color:blue;"&gt;INT&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;@RecCount&lt;span style=""&gt;         &lt;/span&gt;&lt;span style="color:blue;"&gt;INT&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;        &lt;/span&gt;@strSQL&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;1000&lt;span style="color:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:gray;"   &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;INSERT&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; &lt;span style="color:blue;"&gt;INTO&lt;/span&gt; @tmpTable &lt;span style="color:gray;"&gt;(&lt;/span&gt;[name]&lt;span style="color:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT&lt;/span&gt; ROUTINE_SCHEMA&lt;span style="color:gray;"&gt;+&lt;/span&gt;&lt;span style="color:red;"&gt;'.'&lt;/span&gt;&lt;span style="color:gray;"&gt;+&lt;/span&gt;ROUTINE_NAME &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; &lt;span style="color:green;"&gt;INFORMATION_SCHEMA.ROUTINES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;WHERE&lt;/span&gt; ROUTINE_TYPE &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:red;"&gt;'PROCEDURE'&lt;/span&gt; &lt;span style="color:gray;"&gt;AND&lt;/span&gt; ROUTINE_NAME &lt;span style="color:gray;"&gt;NOT&lt;/span&gt; &lt;span style="color:gray;"&gt;LIKE&lt;/span&gt; &lt;span style="color:red;"&gt;'dt_%'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:red;"   &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:red;"   &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:green;"   &gt;-- counters for while&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;SET&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; @RecCount &lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;count&lt;/span&gt;&lt;span style="color:gray;"&gt;(*)&lt;/span&gt; &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; @tmpTable&lt;span style="color:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;SET&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; @RowCount &lt;span style="color:gray;"&gt;=&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;WHILE&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; &lt;span style="color:gray;"&gt;(&lt;/span&gt;@RowCount &lt;span style="color:gray;"&gt;&lt;&lt;/span&gt; @RecCount &lt;span style="color:gray;"&gt;+&lt;/span&gt; 1&lt;span style="color:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT&lt;/span&gt; &lt;span style=""&gt;     &lt;/span&gt;@name &lt;span style="color:gray;"&gt;=&lt;/span&gt; [name]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM&lt;/span&gt; &lt;span style=""&gt; &lt;/span&gt;@tmpTable &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;WHERE&lt;/span&gt; &lt;span style=""&gt;      &lt;/span&gt;PK_ID &lt;span style="color:gray;"&gt;=&lt;/span&gt; @RowCount&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;SET&lt;/span&gt; @strSQL &lt;span style="color:gray;"&gt;=&lt;/span&gt; N&lt;span style="color:red;"&gt;'Grant VIEW Definition&lt;span style=""&gt;  &lt;/span&gt;on '&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:fuchsia;"&gt;rtrim&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:fuchsia;"&gt;cast&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;@name &lt;span style="color:blue;"&gt;AS&lt;/span&gt; &lt;span style="color:blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;128&lt;span style="color:gray;"&gt;)))&lt;/span&gt; &lt;span style="color:gray;"&gt;+&lt;/span&gt; &lt;span style="color:red;"&gt;' to [UserName]'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:green;"&gt;--Execute the Sql&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;EXEC&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;@strSQL&lt;span style="color:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:green;"&gt;--Decrement the counter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;SET&lt;/span&gt; @RowCount &lt;span style="color:gray;"&gt;=&lt;/span&gt; @RowCount &lt;span style="color:gray;"&gt;+&lt;/span&gt; 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:green;"&gt;--reset vars, just in case...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color:blue;"&gt;SET&lt;/span&gt; @name &lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color:gray;"&gt;=&lt;/span&gt; &lt;span style="color:gray;"&gt;null&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;SELECT&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; &lt;span style="color:gray;"&gt;*&lt;/span&gt; &lt;span style="color:blue;"&gt;FROM&lt;/span&gt; @tmpTable&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-2234661648097699246?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/2234661648097699246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=2234661648097699246' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/2234661648097699246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/2234661648097699246'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/10/grant-permissions-to-view-stored.html' title='Grant permissions to view stored procedure text'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-4463124801499888637</id><published>2008-10-16T23:06:00.000-04:00</published><updated>2008-11-02T17:50:57.191-05:00</updated><title type='text'>Database Snapshots</title><content type='html'>&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink 	{color:blue; 	text-decoration:underline; 	text-underline:single;} a:visited, span.MsoHyperlinkFollowed 	{color:purple; 	text-decoration:underline; 	text-underline:single;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal"&gt;Database snapshot is a read-only static database which provides the view of data at a point in time.&lt;span style=""&gt;  &lt;/span&gt;Snapshots use the process of copy on write operation. If a page in the source database is modified for the first time, the original page is copied from the database to the snapshot. Updates after that don’t affect the contents of the snapshot.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Snapshots are very useful to off load historical reports from the OLTP systems. If mirroring is used for high availability, snapshots can be created on the mirror database.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;SQL server management studio does not provide an option to create snapshots. The following T-SQL creates a snapshot named &lt;span style=""&gt;ProductSnap_0100&lt;/span&gt; (0100 is the time stamp of when the database is created i.e. 1am) on the Products database with its sparse file named &lt;span style=""&gt;Products_data.ss.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Drop if the snapshot exists&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;IF&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; [name] &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.databases&lt;/span&gt; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [name] &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'ProductSnap_0100'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt; ProductSnap_0100&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;--Create a snapshot on CORIS database&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt; ProductSnap_0100&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;ON&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;NAME&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; N&lt;span style="color: red;"&gt;'Products_Data'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;FILENAME&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; N&lt;span style="color: red;"&gt;'E:\Snapshot\Products_data_0100.ss'&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;AS&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;SNAPSHOT&lt;/span&gt; &lt;span style="color: blue;"&gt;OF&lt;/span&gt; Products&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=""&gt;Here is an excellent blog about how to switch the reports to the new snapshot.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;a href="http://blogs.msdn.com/sqlcat/archive/2008/08/05/microsoft-sql-server-database-snapshots-and-synonyms.aspx"&gt;http://blogs.msdn.com/sqlcat/archive/2008/08/05/microsoft-sql-server-database-snapshots-and-synonyms.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-4463124801499888637?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/4463124801499888637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=4463124801499888637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4463124801499888637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/4463124801499888637'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/10/database-snapshots.html' title='Database Snapshots'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-5968572723115293380</id><published>2008-04-04T21:02:00.000-04:00</published><updated>2008-11-02T17:48:08.810-05:00</updated><title type='text'>NULLIF - ISNULL - COALESCE</title><content type='html'>&lt;span style="font-size:85%;"&gt;One thing which I always need more information is the NULL, because it is very tricky. Here is just a simple notes….&lt;br /&gt;&lt;br /&gt;NULLIF (expr1, expr2)&lt;br /&gt;&lt;br /&gt;Returns null value when both expression are equal; if not it returns the first expression&lt;br /&gt;&lt;br /&gt;NULLIF is equivalent to the case statement.&lt;br /&gt;&lt;br /&gt;Example from BOL:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;USE AdventureWorks;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;SELECT ProductID, MakeFlag, FinishedGoodsFlag,&lt;br /&gt;NULLIF(MakeFlag,FinishedGoodsFlag)AS 'Null if Equal'&lt;br /&gt;FROM Production.Product&lt;br /&gt;WHERE ProductID &lt; 10;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;SELECT ProductID, MakeFlag, FinishedGoodsFlag,'Null if Equal' =&lt;br /&gt;CASE&lt;br /&gt;WHEN MakeFlag = FinishedGoodsFlag THEN NULL&lt;br /&gt;ELSE MakeFlag&lt;br /&gt;END&lt;br /&gt;FROM Production.Product&lt;br /&gt;WHERE ProductID &lt; 10;&lt;br /&gt;GO&lt;br /&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;&lt;br /&gt;ISNULL (expr_check, expr_replace)&lt;br /&gt;&lt;br /&gt;Replaces null value with the replacement value.&lt;br /&gt;&lt;br /&gt;USE AdventureWorks;&lt;br /&gt;GO&lt;br /&gt;SELECT ProductID,(ISNULL(Weight, 10))&lt;br /&gt;FROM Production.Product;&lt;br /&gt;GO&lt;br /&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;&lt;br /&gt;COALESCE (expr1...exprn)&lt;br /&gt;&lt;br /&gt;Returns first non-null expression among its arguments&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;USE AdventureWorks;&lt;br /&gt;GO&lt;br /&gt;SELECT ProductID,(COALESCE(Weight, 10))&lt;br /&gt;FROM Production.Product;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Difference between ISNULL and COALESCE&lt;br /&gt;&lt;br /&gt;ISNULL takes only 2 parameters. COALESCE can take any number of parameters.&lt;br /&gt;&lt;br /&gt;ISNULL returns the datatype of first parameter whereas the return type of COALESCE is determined&lt;br /&gt;by the data precedence rules; explicit casting should be done to get the desired data type.&lt;br /&gt;&lt;br /&gt;For example the following two statements give different results&lt;br /&gt;&lt;br /&gt;DECLARE @var varchar(2) -- Please use meaningful variable names in real code&lt;br /&gt;SET @var = null&lt;br /&gt;SELECT ISNULL( @var, 'Test' )&lt;br /&gt;SELECT COALESCE( @var, 'Test' ) &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-5968572723115293380?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/5968572723115293380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=5968572723115293380' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5968572723115293380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5968572723115293380'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/04/nullif-isnull-coalesce.html' title='NULLIF - ISNULL - COALESCE'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-1280048788760445641</id><published>2008-04-04T15:22:00.002-04:00</published><updated>2009-10-02T11:16:55.318-04:00</updated><title type='text'>Checking fragmentation in SQL Server 2005</title><content type='html'>&lt;meta equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;meta name="ProgId" content="Word.Document"&gt;&lt;meta name="Generator" content="Microsoft Word 11"&gt;&lt;meta name="Originator" content="Microsoft Word 11"&gt;&lt;link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAKAMU%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:worddocument&gt;   &lt;w:view&gt;Normal&lt;/w:View&gt;   &lt;w:zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:punctuationkerning/&gt;   &lt;w:validateagainstschemas/&gt;   &lt;w:saveifxmlinvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:ignoremixedcontent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:alwaysshowplaceholdertext&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:compatibility&gt;    &lt;w:breakwrappedtables/&gt;    &lt;w:snaptogridincell/&gt;    &lt;w:wraptextwithpunct/&gt;    &lt;w:useasianbreakrules/&gt;    &lt;w:dontgrowautofit/&gt;   &lt;/w:Compatibility&gt;   &lt;w:browserlevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;  &lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:latentstyles deflockedstate="false" latentstylecount="156"&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;style&gt; &lt;!--  /* Font Definitions */  @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt; &lt;/style&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} &lt;/style&gt; &lt;![endif]--&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;SQL Server 2005 provides sys.dm_db_index_physical_stats DMV (dynamic management view) which can be used to check index fragmentation.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;SELECT * FROM sys.dm_db_index_physical_stats(DB_ID('YourDatabaseName'), NULL, NULL, NULL , NULL);&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;If the avg_fragmentation_in_percent &gt; 30 then Rebuild the index&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;If the avg_fragmentation_in_percent &gt;5 and &lt;30 then Reorganize the index&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;br /&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 11pt; font-family: Georgia;"&gt;In a nutshell, rebuilding an index takes more server resources than reorganizing. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-1280048788760445641?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/1280048788760445641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=1280048788760445641' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1280048788760445641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/1280048788760445641'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2008/04/checking-fragmentation-in-sql-server.html' title='Checking fragmentation in SQL Server 2005'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-6010853435035691097</id><published>2007-11-02T23:45:00.000-04:00</published><updated>2008-12-11T03:42:41.832-05:00</updated><title type='text'>Mirroring – Role of Witness Server and Quorum</title><content type='html'>When a witness server is set, a mirroring session (high safety mode with automatic failover mode) needs quorum to keep the database service. A quorum is the minimal relationship among all connected servers required for synchronous database mirroring session.&lt;br /&gt;&lt;br /&gt;Now the next question that comes in mind is about the single point of failure for witness. It is not a single point of failure because if witness fails, principal and mirror will still continue to form a quorum.&lt;br /&gt;&lt;br /&gt;Various types of quorum are possible.&lt;br /&gt;&lt;br /&gt;Say for example&lt;br /&gt;&lt;br /&gt;A = Principal&lt;br /&gt;B = Mirror&lt;br /&gt;C = Witness&lt;br /&gt;&lt;br /&gt;Full Quorum – Both partners and witness are included - A∩B∩C&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_klpXbxeCqZI/R_OxwY9p9RI/AAAAAAAAAAk/1LgrCS64cLM/s1600-h/Image1.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5184683040926463250" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://4.bp.blogspot.com/_klpXbxeCqZI/R_OxwY9p9RI/AAAAAAAAAAk/1LgrCS64cLM/s320/Image1.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;Quorum of partners – Only the two partners are included - A∩B&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_klpXbxeCqZI/R_OzjI9p9SI/AAAAAAAAAAs/4v6gvogZ-IY/s1600-h/Image2.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5184685012316452130" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_klpXbxeCqZI/R_OzjI9p9SI/AAAAAAAAAAs/4v6gvogZ-IY/s320/Image2.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Quorum with witness and partner – Witness and one of the partners are included C∩(AUB)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_klpXbxeCqZI/R_OzwI9p9TI/AAAAAAAAAA0/KoCo9ALsgPE/s1600-h/Image3.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5184685235654751538" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://3.bp.blogspot.com/_klpXbxeCqZI/R_OzwI9p9TI/AAAAAAAAAA0/KoCo9ALsgPE/s320/Image3.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Quorum loses sessions&lt;br /&gt;&lt;br /&gt;If all the servers are disconnected then the session loses quorum&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_klpXbxeCqZI/R_O0JY9p9UI/AAAAAAAAAA8/K5zjkxJN_Z4/s1600-h/Image4.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5184685669446448450" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://4.bp.blogspot.com/_klpXbxeCqZI/R_O0JY9p9UI/AAAAAAAAAA8/K5zjkxJN_Z4/s320/Image4.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Now that we know all possible types of quorum, let’s see how each one affects the database and application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_klpXbxeCqZI/R_O2BY9p9XI/AAAAAAAAABU/KeRvFNNmRDg/s1600-h/Image5.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5184687731030750578" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 367px; CURSOR: hand; HEIGHT: 251px" height="215" alt="" src="http://4.bp.blogspot.com/_klpXbxeCqZI/R_O2BY9p9XI/AAAAAAAAABU/KeRvFNNmRDg/s320/Image5.JPG" width="375" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_klpXbxeCqZI/R_O1jo9p9WI/AAAAAAAAABM/uF8yCcJaQ00/s1600-h/Image5.JPG"&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_klpXbxeCqZI/R_O1jo9p9WI/AAAAAAAAABM/uF8yCcJaQ00/s1600-h/Image5.JPG"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;If witness is disconnected when either partner goes down, the database is unavailable since quorum cannot be formed. If the session loses quorum, then the database will not be available until the quorum is re-established. &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-6010853435035691097?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/6010853435035691097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=6010853435035691097' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6010853435035691097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6010853435035691097'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/11/mirroring-role-of-witness-server-and.html' title='Mirroring – Role of Witness Server and Quorum'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_klpXbxeCqZI/R_OxwY9p9RI/AAAAAAAAAAk/1LgrCS64cLM/s72-c/Image1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-6410469447600729590</id><published>2007-04-01T15:43:00.000-04:00</published><updated>2008-11-02T17:45:19.524-05:00</updated><title type='text'>SQL Server 2005 Database Mirroring</title><content type='html'>I have been working with database mirroring feature in SQL Server 2K5 and these are some of interesting points I have noted during setting up the process.&lt;br /&gt;&lt;br /&gt;1. In SQL Server 2005 SP1 and later versions, database mirroring is fully supported and is made available for general production use. To use database mirroring in a production environment, upgrade to SQL Server 2005 Service Pack 1 (SP1).&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://support.microsoft.com/kb/907741"&gt;http://support.microsoft.com/kb/907741&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. An error occurred while starting mirroringDatabase Mirroring Transport is disabled in the endpoint configuration.(Microsoft SQL Server, Error: 1486)&lt;br /&gt;&lt;br /&gt;Solution:  Run DBCC TRACEON (1400)&lt;br /&gt;&lt;br /&gt;3. The mirror database, "XXX", has insufficient transaction log data to preserve the log backup chain of the principal database.  This may happen if a log backup from the principal database has not been taken or has not been restored on the mirror database. (Microsoft SQL Server, Error: 1478)&lt;br /&gt;&lt;br /&gt;Solution: After the full backup on the principal, you need to backup the Transaction log on the principal server. Restore the full backup on mirror in ‘NORECOVERY MODE’ and then restore the Transaction log in ‘NORECOVERY MODE’&lt;br /&gt;&lt;br /&gt;4. Can we use database mirroring for the purpose of transferring data from production to test or development server?&lt;br /&gt;&lt;br /&gt;In mirroring, if the first server should become unavailable, the system will failover to the mirrored database and SQL Server, helping to ensure high availability. I don't think you want to failover to test or development box.However, you can use Database Mirroring and create a Database Snapshot against the mirror. This Database Snapshot can be periodically dropped and recreated in order to give access to more up to date information. You can use this snapshot for reports or testing.&lt;br /&gt;&lt;br /&gt;5. Can we use Database mirroring with Log Shipping?&lt;br /&gt;&lt;br /&gt;This MS article explains it clearly&lt;br /&gt;&lt;br /&gt; &lt;a href="http://msdn2.microsoft.com/en-us/library/ms187016.aspx" target="_blank"&gt;http://msdn2.microsoft.com/en-us/library/ms187016.aspx&lt;/a&gt;&lt;br /&gt; &lt;span style="font-family:times new roman;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-6410469447600729590?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/6410469447600729590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=6410469447600729590' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6410469447600729590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/6410469447600729590'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/04/sql-server-2005-database-mirroring.html' title='SQL Server 2005 Database Mirroring'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-3795789510124870074</id><published>2007-03-24T22:42:00.000-04:00</published><updated>2008-11-02T17:43:52.701-05:00</updated><title type='text'>T-SQL Convert Hex value to Integer</title><content type='html'>&lt;span style="font-family:times new roman;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;--Convert Hex value to int&lt;br /&gt;SELECT CONVERT(INT, 0x000FFEFF)&lt;br /&gt;&lt;br /&gt;--Convert int value to hex&lt;br /&gt;SELECT CONVERT(VARBINARY(8), 1048319)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-3795789510124870074?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/3795789510124870074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=3795789510124870074' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3795789510124870074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3795789510124870074'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/03/t-sql-convert-hex-value-to-integer.html' title='T-SQL Convert Hex value to Integer'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-3231379098548624396</id><published>2007-03-23T22:53:00.000-04:00</published><updated>2008-11-02T17:42:56.321-05:00</updated><title type='text'>SQL Server 2005 Access to System tables</title><content type='html'>&lt;span style="font-family:times new roman;"&gt;In SQL2K5 system data is hidden in resource tables and cannot be accessed. Instead, there are number of views which can provide the information.&lt;br /&gt;&lt;br /&gt;Catalog Views – Shows metadata that describes the objects in an instance&lt;br /&gt;Information Schema Views - They have the same functionality as in 2000 Provides internal view of SQL Server meta data&lt;br /&gt;Compatibility Views – These are for backward compatibility. Beware that columns that previously were undocumented typically now only have NULL or 0&lt;br /&gt;Dynamic Management Views – They provide inside details of SQL Server state data, which can be used to check the health of SQL Server instance. Consists of both views and table valued functions&lt;br /&gt;&lt;br /&gt;Also from BOL, the catalog views and the compatibility views have restricted visibility, so by default they only return information about objects to which the user has some rights.&lt;br /&gt;&lt;br /&gt;Mapping SQL Server 2000 System Tables to SQL Server 2005 System Views&lt;br /&gt;&lt;/span&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms187997.aspx"&gt;&lt;span style="font-family:times new roman;"&gt;http://msdn2.microsoft.com/en-us/library/ms187997.aspx&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-3231379098548624396?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/3231379098548624396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=3231379098548624396' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3231379098548624396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3231379098548624396'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/03/sql-server-2005-access-to-system-tables.html' title='SQL Server 2005 Access to System tables'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-7508582943195448813</id><published>2007-03-23T17:40:00.000-04:00</published><updated>2008-11-02T17:41:53.160-05:00</updated><title type='text'>SQL Server Management Studio – Editor Color Coding</title><content type='html'>&lt;span style="font-family:times new roman;"&gt;In Management studio, when you open query editor, there is a thin yellow vertical line in the left margin for each line you type. Sometimes the line disappears and sometimes it is green in color. Did you ever notice that? If not, continue reading……&lt;br /&gt;&lt;br /&gt;These colors represent the modifications done to the file.&lt;br /&gt;&lt;br /&gt;Yellow –modification, not saved&lt;br /&gt;Green – modification, saved&lt;br /&gt;No Color – no modification&lt;br /&gt;&lt;br /&gt;Now, can you change these colors? Ofcourse, goto Tools-&gt;Options-&gt;Environment -&gt;Fonts and Colors. You can change the colors for various display items.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-7508582943195448813?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/7508582943195448813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=7508582943195448813' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7508582943195448813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/7508582943195448813'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/03/sql-server-management-studio-editor.html' title='SQL Server Management Studio – Editor Color Coding'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-2885776578988007078</id><published>2007-02-07T21:38:00.000-05:00</published><updated>2008-11-02T17:39:43.565-05:00</updated><title type='text'>SQL Server - Find primary keys in a table</title><content type='html'>&lt;span style="font-family:times new roman;"&gt;To find primary key in a given table :&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Times New Roman;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;Option 1: sp_pkeys 'yourtablename'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;Option 2: select * from INFORMATION_SCHEMA.TABLE_CONSTRAINTS&lt;br /&gt;where table_name = 'yourtablename' and constraint_type = 'primary key'&lt;br /&gt;&lt;br /&gt;Option 3: sp_help 'yourtablename'&lt;br /&gt;&lt;br /&gt;To find all primary keys in database:&lt;br /&gt;&lt;br /&gt;Use yourdatabasename&lt;br /&gt;select c.COLUMN_NAME ,c.CONSTRAINT_NAME,C.table_name&lt;br /&gt;from INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk ,&lt;br /&gt;INFORMATION_SCHEMA.KEY_COLUMN_USAGE c&lt;br /&gt;where CONSTRAINT_TYPE = 'PRIMARY KEY'&lt;br /&gt;and c.TABLE_NAME = pk.TABLE_NAME&lt;br /&gt;and c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME&lt;br /&gt;&lt;br /&gt;These would work for both SQL Server 2K and SQL Server 2K.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-2885776578988007078?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/2885776578988007078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=2885776578988007078' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/2885776578988007078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/2885776578988007078'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/02/sql-server-find-primary-keys-in-table.html' title='SQL Server - Find primary keys in a table'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-3679768882975170038</id><published>2007-02-07T21:20:00.000-05:00</published><updated>2008-11-02T17:40:53.778-05:00</updated><title type='text'>Business Intelligence Studio - Installation error</title><content type='html'>&lt;span style="font-family:times new roman;"&gt;After installing SQL Server developer edition, Business Intelligence Studio starts looking for file devenv.exe.&lt;br /&gt;&lt;br /&gt;To resolve this issue:&lt;br /&gt;1. You should make sure that Visual Studio is still installed.&lt;br /&gt;2. If you didn't previously have VS installed, the BI Dev Studio installation will install a VS shell called Visual Studio Premier Partner Edition.&lt;br /&gt;3. Look in Add or Remove Programs for “Microsoft Visual Studio Premier Partner Edition”. If you don't find any entry for Visual Studio go to the location for SQL Server setup and run \Setup\vs_setup.exe. (Usually in CD #2 under setup)&lt;br /&gt;4. After VSShell is installed repair the BI Studio installation by running the following from the command line from the .\Tools directory: start /wait setup.exe /qb REINSTALL=SQL_WarehouseDevWorkbench REINSTALLMODE=OMUS&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-3679768882975170038?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/3679768882975170038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=3679768882975170038' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3679768882975170038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3679768882975170038'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/02/business-intelligence-studio.html' title='Business Intelligence Studio - Installation error'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-5879211867973525279</id><published>2007-01-31T22:37:00.000-05:00</published><updated>2008-11-02T17:38:27.359-05:00</updated><title type='text'>Import/Export between SQL 2005 and 2000</title><content type='html'>&lt;span style="font-family:times new roman;"&gt;Due to architectual differences, you can not restore a database backup from higher version to Lower version [SQL 2005 to SQL 2000]. Once it is attached or restored to a 2005 instance it can not go back intact.&lt;br /&gt;&lt;br /&gt;One question which comes into mind immediately is, what if DB is set to SQL 2000 compatibility level? Compatibility level is for client connection behavior. On-disk it is still SQL 2005.&lt;br /&gt;One solution is to create the database manually, create objects and use SSIS/DTS/BCP to transfer the data.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-5879211867973525279?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/5879211867973525279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=5879211867973525279' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5879211867973525279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/5879211867973525279'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/01/importexport-between-sql-2005-and-2000.html' title='Import/Export between SQL 2005 and 2000'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8254475978080599910.post-3358150698404125158</id><published>2007-01-31T20:35:00.000-05:00</published><updated>2008-11-02T17:36:57.534-05:00</updated><title type='text'>Enable xp_cmdshell</title><content type='html'>&lt;p&gt;&lt;span style="font-family:times new roman;"&gt;With SQL Server 2005, xp_cmdshell is disabled by default&lt;br /&gt;&lt;br /&gt;To enable this feature:&lt;br /&gt;&lt;br /&gt;Option 1: Using T-SQL&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:times new roman;"&gt;--Enable the feature&lt;br /&gt;EXEC sp_configure 'xp_cmdshell', 1&lt;br /&gt;GO&lt;br /&gt;-- To update the currently configured value for this feature.&lt;br /&gt;RECONFIGURE&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:times new roman;"&gt;Option 2: SQL Server 2005 Surface Area Configuration tool&lt;br /&gt;&lt;br /&gt;From Surface Area Configuration Tools -&gt; Choose “Surface Area Configuration for Features” &gt; Check “Enable xp_cmdshell”&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8254475978080599910-3358150698404125158?l=sqlserverimpressions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlserverimpressions.blogspot.com/feeds/3358150698404125158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8254475978080599910&amp;postID=3358150698404125158' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3358150698404125158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8254475978080599910/posts/default/3358150698404125158'/><link rel='alternate' type='text/html' href='http://sqlserverimpressions.blogspot.com/2007/01/enable-xpcmdshell.html' title='Enable xp_cmdshell'/><author><name>Sireesha</name><uri>http://www.blogger.com/profile/08041001699046302921</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
