<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CkcDSH45fCp7ImA9WhRVGUg.&quot;"><id>tag:blogger.com,1999:blog-12327506</id><updated>2012-01-19T10:44:39.024+05:30</updated><category term="File Size" /><category term="Denali" /><category term="MCM" /><category term="UNION" /><category term="Temp Tables" /><category term="Index maintenance" /><category term="Architecture" /><category term="Powershell" /><category term="Tool Evaluation" /><category term="Statistics" /><category term="IIS Database Manager" /><category term="Replication" /><category term="Constraints" /><category term="Job scheduling" /><category term="filtered index" /><category term="Query Optimization" /><category term="coding standards" /><category term="Authorization" /><category term="Recovery Model" /><category term="Security" /><category term="Puzzle" /><category term="vacancies" /><category term="NOT EXISTS" /><category term="LEFT JOIN" /><category term="Administration" /><category term="troubleshooting" /><category term="Performance Optimization" /><category term="Identity" /><category term="Active Active Clustering" /><category term="UNION ALL" /><category term="Tech Ed" /><category term="dm_db_index_physical_stats" /><category term="Backup" /><category term="SQLServer Installation" /><category term="dynamic Management views" /><category term="Index" /><category term="OR" /><category term="Career" /><category term="Row Count" /><category term="Book" /><category term="Page" /><category term="SSIS" /><category term="System Procedures" /><category term="Dynamic SQL" /><category term="What's New" /><category term="index fragmentation" /><category term="Error handling" /><category term="REVOKE" /><category term="Certification" /><category term="ALTER TABLE" /><category term="SQL Server Clustering" /><category term="Hierarchical Data" /><category term="Restore" /><category term="Log Shipping" /><category term="Internals" /><category term="MVP" /><category term="Seek" /><category term="XML" /><category term="Data Types" /><category term="deprecated features" /><category term="errorlog" /><category term="Table Partitioning" /><category term="Fragmentation" /><category term="NOT IN" /><category term="TSQL" /><category term="Average" /><category term="Parameters" /><category term="Recompilation" /><category term="Business" /><category term="Transaction Log" /><category term="Execution Plan" /><category term="Learning" /><category term="My Articles" /><category term="nonclustered index" /><category term="GRANT" /><category term="MCITP" /><category term="checkpoint" /><category term="Database" /><category term="String Manipulation" /><category term="DENY" /><category term="DROPping and ADDing COLUMN" /><category term="DBCC" /><category term="SSSLUG" /><category term="Database Testing" /><category term="Training" /><category term="Scan" /><category term="Split" /><category term="Physical Join Operators" /><category term="Database Design" /><title>Encounter with Databases</title><subtitle type="html">All about the technologies I work with - SQL Server, other relational &amp;amp; non relational databases, PowerShell  and scripting languages.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://preethiviraj.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>96</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/EncounterWithSqlServer" /><feedburner:info uri="encounterwithsqlserver" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>EncounterWithSqlServer</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;CUMGQn8-cSp7ImA9WhRVEkk.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-3534458195422534451</id><published>2012-01-11T06:27:00.000+05:30</published><updated>2012-01-11T06:27:03.159+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-11T06:27:03.159+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVP" /><category scheme="http://www.blogger.com/atom/ns#" term="Certification" /><title>MVP Again!</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-NuJgUyCHTmM/TwzdG388_lI/AAAAAAAAAeM/yHQA6IigfvE/s1600/DSC01244.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="133" src="http://1.bp.blogspot.com/-NuJgUyCHTmM/TwzdG388_lI/AAAAAAAAAeM/yHQA6IigfvE/s200/DSC01244.JPG" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
Thanks to those who worked hard to get this again for me. &amp;nbsp;How can I forget the friends encouraged me. &lt;br /&gt;
When looking back, &amp;nbsp;I need to admit that I can still say that there are many things I can do better and I hope to do it better this time.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-3534458195422534451?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hx84Sw4X66cAl6ewlcKmBadxpFo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hx84Sw4X66cAl6ewlcKmBadxpFo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hx84Sw4X66cAl6ewlcKmBadxpFo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hx84Sw4X66cAl6ewlcKmBadxpFo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/ECzKeQ3pH44" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/3534458195422534451/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2012/01/mvp-again.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3534458195422534451?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3534458195422534451?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/ECzKeQ3pH44/mvp-again.html" title="MVP Again!" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-NuJgUyCHTmM/TwzdG388_lI/AAAAAAAAAeM/yHQA6IigfvE/s72-c/DSC01244.JPG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2012/01/mvp-again.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIGR3Y7fCp7ImA9WhRWFUs.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-4323996608318293407</id><published>2012-01-03T09:35:00.001+05:30</published><updated>2012-01-03T09:35:26.804+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-03T09:35:26.804+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Career" /><category scheme="http://www.blogger.com/atom/ns#" term="vacancies" /><title>SQL Server database professionals needed</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Hi readers,&lt;br /&gt;
If you are from Sri Lanka, I need to share this info with you. There are organizations searching for SQL Server database administrators, database developers and similar positions. As of now we do not have a place to share the resume.&amp;nbsp; But if you are interested in similar positions. Please let me know. I can share your info with others.&amp;nbsp; Offers include working abroad. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-4323996608318293407?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/vzKAkpJwOn9H9nX1sUYFyuMyd4Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vzKAkpJwOn9H9nX1sUYFyuMyd4Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/vzKAkpJwOn9H9nX1sUYFyuMyd4Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vzKAkpJwOn9H9nX1sUYFyuMyd4Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/eByORzS0P8A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/4323996608318293407/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2012/01/sql-server-database-professionals.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4323996608318293407?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4323996608318293407?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/eByORzS0P8A/sql-server-database-professionals.html" title="SQL Server database professionals needed" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2012/01/sql-server-database-professionals.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04EQX06eSp7ImA9WhRWFUs.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-8340863714924265708</id><published>2012-01-01T00:00:00.000+05:30</published><updated>2012-01-03T09:08:20.311+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-03T09:08:20.311+05:30</app:edited><title>Happy New year!</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-9s6L0Ed1odA/TwJ2cp3WdcI/AAAAAAAAAeE/4mdITtm19h4/s1600/New+Year+2012.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="426" src="http://2.bp.blogspot.com/-9s6L0Ed1odA/TwJ2cp3WdcI/AAAAAAAAAeE/4mdITtm19h4/s640/New+Year+2012.gif" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-8340863714924265708?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hZVduiaF1FYRinVk_tKF_MgTfTY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hZVduiaF1FYRinVk_tKF_MgTfTY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hZVduiaF1FYRinVk_tKF_MgTfTY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hZVduiaF1FYRinVk_tKF_MgTfTY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/eKsSp_JpqX4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/8340863714924265708/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2012/01/blog-post.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/8340863714924265708?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/8340863714924265708?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/eKsSp_JpqX4/blog-post.html" title="Happy New year!" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-9s6L0Ed1odA/TwJ2cp3WdcI/AAAAAAAAAeE/4mdITtm19h4/s72-c/New+Year+2012.gif" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2012/01/blog-post.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0AER3c6cSp7ImA9WhRTEUQ.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-9161053258327763356</id><published>2011-11-02T07:38:00.000+05:30</published><updated>2011-11-02T07:38:26.919+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-02T07:38:26.919+05:30</app:edited><title>Will The Performance Improve If The Database Size is Smaller?</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Few days back, when I was speaking at SSLUG (SQL Server Sri Lanka User Group) meeting on "managing VLDB" (VLDB stands for Very Large Data Bases) there was a question came on improving the performance of VLDB. There was a participant suggested that by shrinking the database we could improve the performance. I noted it then and answered later, but it could be useful for many if I share in the blog. &amp;nbsp;So I am sharing it here for the benefit of many.&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;b&gt;Argument: &lt;/b&gt;&amp;nbsp;Large databases may take longer time to execute a query because scan operations may have to read more pages. &lt;/blockquote&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;b&gt;Answer: &lt;/b&gt;If you have an operation which scans the entire database (generally a maintenance or troubleshooting related operation) yes you may have to scan more pages. &amp;nbsp;However when you run a query against tables, you will touch only the pages allocated to the table and indexes. &amp;nbsp;If the table is clustered, each page will have a pointer to the next page and all read operations happen based on these pointers. &amp;nbsp;The performance is better, if you have read forward only. when you have free pages at the end of the database, it will not be touched at all. But if you have free pages &amp;nbsp;in between, shrink operation moves the pages at the end to the free space available. It will make the physical order different from logical order and forces read backward. This is the major concern for performance.&lt;/blockquote&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;b&gt;Argument:&lt;/b&gt;&amp;nbsp;Shrink operations reduces the pages occupied by an object&lt;/blockquote&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;b&gt;Answer:&lt;/b&gt;&amp;nbsp;NO. Please note this point: &amp;nbsp;&lt;b&gt;Shrink operation does not remove the free space available within a page. Shrink operation does not compress the data either.&lt;/b&gt;&amp;nbsp;The free space within a page can occur due to many reasons. &lt;/blockquote&gt;
&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;If the clustered index was created with a fill factor &amp;nbsp;between 1-99 generally you expect some space within a page when the index is created/rebuilt.&lt;/li&gt;
&lt;li&gt;When page split happens due to updates there is some space left in old page.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;When a row within a page is deleted their is free space created. (Okay, SQL Server does not initialize every bit of deleted row to 0. But rather the entry is removed from index and row mark within a page. SQL Server treats that area as free space)&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;blockquote class="tr_bq"&gt;
Shrink operations work at page level and not at object level or row level. &amp;nbsp;If there is a free page in the middle and last non-free page will be moved there and that last page will be marked as free. Then it changes the pointers in the pages accordingly At the end, the free pages at the end could truncated if the options are set properly. The internal fragmentation (the fragmentation happens within a page due to page splits etc.)&lt;/blockquote&gt;
Then what is the mechanism to remove the fragmentation? The answer is to rebuild the clustered index. As the data is ordered in the clustered index key, it can move the data pages according to the clustered key order. &amp;nbsp;This is why rebuilding a clustered index is a resource consuming operation.&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-9161053258327763356?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/W4dEBh5y0RZtfowIfw__eoxTtGg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W4dEBh5y0RZtfowIfw__eoxTtGg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/W4dEBh5y0RZtfowIfw__eoxTtGg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W4dEBh5y0RZtfowIfw__eoxTtGg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/zadEMjNzRU4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/9161053258327763356/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/11/will-performance-improve-if-database.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/9161053258327763356?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/9161053258327763356?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/zadEMjNzRU4/will-performance-improve-if-database.html" title="Will The Performance Improve If The Database Size is Smaller?" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/11/will-performance-improve-if-database.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEUDQXw5eCp7ImA9WhdaFEg.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-7527090245133033631</id><published>2011-09-14T12:58:00.000+05:30</published><updated>2011-10-24T17:07:50.220+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-24T17:07:50.220+05:30</app:edited><title>SQL Server OLEDB Deprecation</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Few days&amp;nbsp;back I sent a tweet update on this matter using my twitter account &lt;a href="http://twitter.com/#1/preethi_1965"&gt;@preethi_1965&lt;/a&gt;&lt;br /&gt;
For those who want to&amp;nbsp;hear more on this, here there are few things:&lt;br /&gt;
&lt;br /&gt;
Microsoft has officially announced that they are moving away from OLEDB.&amp;nbsp;&lt;br /&gt;
&lt;a href="http://blogs.msdn.com/b/sqlnativeclient/archive/2011/08/29/microsoft-is-aligning-with-odbc-for-native-relational-data-access.aspx"&gt;http://blogs.msdn.com/b/sqlnativeclient/archive/2011/08/29/microsoft-is-aligning-with-odbc-for-native-relational-data-access.aspx&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://social.technet.microsoft.com/Forums/en/sqldataaccess/thread/e696d0ac-f8e2-4b19-8a08-7a357d3d780f"&gt;http://social.technet.microsoft.com/Forums/en/sqldataaccess/thread/e696d0ac-f8e2-4b19-8a08-7a357d3d780f&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
There could be a couple of reasons behind it.&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;SNAC OLEDB does not scale upt o the customer expectation&lt;/li&gt;
&lt;li&gt;ODBC is industry standard and It supports cross platform. To meet the complex market and technology&amp;nbsp;needs, Microsoft needs to Maintain ODBC anyway.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;Maintaining both OLEDB and ODBC at the same time providing new features is a difficult task.&lt;/li&gt;
&lt;li&gt;Interestingly, Initially Microsoft pushed for OLEDB as it can give a better performance over ODBC.&amp;nbsp; However, especially in 64 bit platforms, OLEDB didn't takeover.&amp;nbsp; According to insiders, OLEDB takes shorter paths, less code and&amp;nbsp;provides better performance.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
With that said, SQL Server "Denali" most probably be the last version OLEDB.&amp;nbsp; As Denali CTP 3 is not yet feature complete, I expect another 6 to&amp;nbsp;12 months for the RTM to be released.&amp;nbsp;It gives us space&amp;nbsp;of another&amp;nbsp;seven to ten years to change the code which uses OLEDB.&amp;nbsp; Until then we are rightfully expect Microsoft to support OLEDB.&lt;br /&gt;
&lt;br /&gt;
Just a note, OLEDB is shipped in two forms.&amp;nbsp;SNC(SQL Server Native Client) and MSOLAP.&amp;nbsp;Microsoft is deprecating only the SNC&amp;nbsp;OLEDB.&amp;nbsp;OLEDB for other platforms will be supported continually.&amp;nbsp;SSIS, SSRS and SSAS clients need not to be panicked. Especially SSIS is heavily depending on OLEDB currently and until something else is developed and in place for few years, it will be supported. &lt;br /&gt;
&lt;br /&gt;
I saw an interesting article on&amp;nbsp;&amp;nbsp;&lt;a href="http://blogs.msdn.com/b/analysisservices/archive/2011/09/14/impact-of-the-sql-server-ole-db-deprecation-on-analysis-services.aspx"&gt;Impact of the SQL Server OLE DB Deprecation on Analysis Services&lt;/a&gt;.&lt;br /&gt;
Please have a look.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-7527090245133033631?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/h0b85fhdk1qb8hGbUvHcVeLAxxg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/h0b85fhdk1qb8hGbUvHcVeLAxxg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/h0b85fhdk1qb8hGbUvHcVeLAxxg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/h0b85fhdk1qb8hGbUvHcVeLAxxg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/Pmqz17nv_ok" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/7527090245133033631/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/09/sql-server-oledb-deprecation.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/7527090245133033631?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/7527090245133033631?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/Pmqz17nv_ok/sql-server-oledb-deprecation.html" title="SQL Server OLEDB Deprecation" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/09/sql-server-oledb-deprecation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEEFR3c-fCp7ImA9WhdWFEQ.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-1577177255312944986</id><published>2011-09-08T20:55:00.007+05:30</published><updated>2011-09-08T21:13:36.954+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-08T21:13:36.954+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Security" /><title>Rename sa login to improve security</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Whenever I speak about security, I tell that we should minimally use sa account. SQL server by default keep the sa account disabled. &lt;br /&gt;
In addition to this, we can restrict sysadmin rights to few people, and give only what is needed. &lt;br /&gt;
&lt;br /&gt;
Recently I found out that you can even rename sa account. It is a better practice so that people will not even know what the sa account is.&lt;br /&gt;
Simply go to security and logins and select sa account in object explorer. Right click there and select “rename” option. You replace the sa name with the new name and you are done. All the database user accounts mapped to sa login and sa owned jobs and objects will work without any issues. This is because even though you have renamed the login name you are still using the same SID 0x01&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-VWwFbhugSSo/TmjijkeeOSI/AAAAAAAAAcQ/ltd0aluxzNQ/s1600/rename+sa.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" nba="true" src="http://3.bp.blogspot.com/-VWwFbhugSSo/TmjijkeeOSI/AAAAAAAAAcQ/ltd0aluxzNQ/s1600/rename+sa.JPG" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This means, you have an additional security; earlier Brute force mechanism needs to get only the password of sa. (It already know that they have a user named sa and sa has sysadmin rights. ) Now needs to pass three different options. Finding a valid login name; getting the password; the login should sysadmin have access.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-1577177255312944986?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/rxTaZ6JFIj57E-TREz-oQU66WFs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rxTaZ6JFIj57E-TREz-oQU66WFs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/rxTaZ6JFIj57E-TREz-oQU66WFs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rxTaZ6JFIj57E-TREz-oQU66WFs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/YxgTzTjt9cc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/1577177255312944986/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/09/rename-sa-login-to-improve-security.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/1577177255312944986?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/1577177255312944986?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/YxgTzTjt9cc/rename-sa-login-to-improve-security.html" title="Rename sa login to improve security" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-VWwFbhugSSo/TmjijkeeOSI/AAAAAAAAAcQ/ltd0aluxzNQ/s72-c/rename+sa.JPG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/09/rename-sa-login-to-improve-security.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkQDSHk9fip7ImA9WhdWEUg.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-8239176225788241387</id><published>2011-09-04T23:16:00.000+05:30</published><updated>2011-09-04T23:16:19.766+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-04T23:16:19.766+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Tool Evaluation" /><category scheme="http://www.blogger.com/atom/ns#" term="Certification" /><title>Tool Evaluation:  uCertify PrepEngine for 70-432:  SQL Server Implementation and Maintenance.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div closure_uid_ns91f8="266"&gt;&lt;span closure_uid_ns91f8="265" style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Recently I was asked to evaluate an exam tool. A tool developed for 70-432 exam: &lt;strong&gt;MSTS: Implementation and maintenance of SQL Server 2008&lt;/strong&gt;.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div closure_uid_ns91f8="324"&gt;&amp;nbsp;&lt;/div&gt;&lt;span closure_uid_ns91f8="268" style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Before talking about the tool, Let me introduce my readers to the tool itself. It is “&lt;strong&gt;uCertify PrepEngine&lt;/strong&gt;” from uCertify.com. The tool helps the user to learn and practice for the said exam before&amp;nbsp;taking the actual exam. I know that they provide the preparation tool for various other exams too.&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;To use the tool, you have two options: An evaluation version which gives limited usage. If you find it useful, (There is high possibility you may find it useful) you can upgrade it to a licensed edition.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div closure_uid_ns91f8="326"&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="separator" closure_uid_ns91f8="368" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div closure_uid_ns91f8="325"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Let me set this clear first: 100% money back guarantee and braindump free. &lt;/span&gt;&lt;/div&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Ucertify supports 100% money back guarantee. In their own words, if you don’t get certified in the first attempt, fax them your score and we will return your money. As simple as that.&lt;/span&gt;&lt;/li&gt;
&lt;li closure_uid_ns91f8="390"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;But it does not mean it is another collection of braindump. In fact, it is brain dump free. That means, you can learn the basics and sit for the exam and pass the exam without cheating. You can really be proud of your results.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div closure_uid_ns91f8="390"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" closure_uid_ns91f8="420" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-w-4O7ZHhnlA/TmO4W2ETrDI/AAAAAAAAAcI/k22ZaIHejZk/s1600/ucertify.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-w-4O7ZHhnlA/TmO4W2ETrDI/AAAAAAAAAcI/k22ZaIHejZk/s1600/ucertify.JPG" xaa="true" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" closure_uid_ns91f8="420" style="clear: both; text-align: center;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Doesn’t that sound interesting? Don't you want to download the evaluation version?&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: Trebuchet MS;"&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;div closure_uid_ns91f8="322" style="text-align: left;"&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span closure_uid_ns91f8="270" style="font-family: Trebuchet MS;"&gt;The tool is available &lt;a href="http://www.ucertify.com/exams/Microsoft/70-432.html"&gt;here&lt;/a&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;It has 14 questions on diagnostic test which allows the user to evaluate where he/she stands in terms of the exam and identify the areas which needs special concentration. It also gives changes of five practice tests (each on with 45 questions) and one final test with 65 questions. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;In addition to this user is allowed to take adaptive test, even to customize a test based on the time available. This means, if you have only five minutes of spare time, you can take a “miniature exam” during that time. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Questions are categorized to single choice, multiple selection and simulation types similar to the actual exam. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;The tool also provides interactive quiz with 126 questions&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Questions cover the areas related to the exam. Based on the answers student can find out the areas he/she needs to concentrate. &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Answers are supported by detailed explanation, facts and reference material&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Users can add their notes, tags to the questions, Can retake the same exam multiple times. With randomize options, it is hard to answer the question correctly by memorizing the answers, unless you really understand the concepts. &lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;To prepare for the exam, it allows many supporting material&lt;/span&gt;&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;&lt;div closure_uid_ns91f8="421"&gt;&lt;span closure_uid_ns91f8="423" style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;385 study notes, 3 general articles,&amp;nbsp;8 How to articles&amp;nbsp;&amp;nbsp;and 6 study tips&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;span closure_uid_ns91f8="422" style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Keeps flash cards. You can create your own card in the form of study notes.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Simple articles on How to perform certain actions on SQL Server&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Study notes mainly on “what is “ gives introduction to different topics in SQL Server.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;It has the facility to print the questions and answers too. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Some good things:&lt;/span&gt;&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span closure_uid_ns91f8="425" style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Features: Give feedback, Take notes and print the notes/ questions etc. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;The tool allows the students to time box the exams. That means it prevents the users from being carried away with some questions/areas.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Create a Custom exam based on the time the user has. Even on the last minute, the student can sit for an exam of an area which he/she needs reassurance about his/her competence.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;The detailed explanation is something great. It not just gives explanation on why a particular answer is right, but also why the other answers are wrong. Additionally it gives some reference from MSDN too.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;It covers the exam content from what Microsoft has published. I am not an exam expert to authorize whether it covers all the details of the exam, But, I feel that training the students to face the real hard questions (even if they necessarily be part of the exam),will increase the confidence level f the students.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Few enhancements I like to have:&lt;/span&gt;&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Most of the questions cover the basics of the topics and do not concentrate on advanced areas. For example, In SQL Server 2008, few performance optimizations were done over replication and database mirroring. The questions were concentrating on these high availability features, but not on the performance optimizations. Another good thing to learn I like to see is combining multiple high availability features. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;In addition to the explanation, some information on further reading (to get more in-depth knowledge on the subject ) would a nice to have feature and increase the rating of the tool.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Almost all the notes are about "what is xxxx" I like to see more on "what suits where " or "how to " &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div closure_uid_ns91f8="426"&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Few negative points (Actually I have only one): &lt;/span&gt;&lt;/div&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Some facts about the exam are outdated/incomplete. For example, Microsoft has increased the exam fees few weeks back. But still the tool says the older price. Another thing I noticed was it failed to mention that students from non English speaking countries get few additional minutes as Microsoft feels that they need more time to read and understand the questions.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style="font-family: &amp;quot;Trebuchet MS&amp;quot;, sans-serif;"&gt;Please note that I am evaluating only for 70-432 exam, my comments are limited to it only. &lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-8239176225788241387?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3VSgvd_h-E49imlsh_mS27LYXB4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3VSgvd_h-E49imlsh_mS27LYXB4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3VSgvd_h-E49imlsh_mS27LYXB4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3VSgvd_h-E49imlsh_mS27LYXB4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/HfWsUhsRXOM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/8239176225788241387/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/09/tool-evaluation-ucertify-prepengine-for.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/8239176225788241387?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/8239176225788241387?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/HfWsUhsRXOM/tool-evaluation-ucertify-prepengine-for.html" title="Tool Evaluation:  uCertify PrepEngine for 70-432:  SQL Server Implementation and Maintenance." /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-w-4O7ZHhnlA/TmO4W2ETrDI/AAAAAAAAAcI/k22ZaIHejZk/s72-c/ucertify.JPG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/09/tool-evaluation-ucertify-prepengine-for.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YEQnszeip7ImA9WhdXF0w.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-7353593272114114149</id><published>2011-08-30T20:07:00.001+05:30</published><updated>2011-08-30T20:08:23.582+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T20:08:23.582+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="UNION ALL" /><category scheme="http://www.blogger.com/atom/ns#" term="UNION" /><category scheme="http://www.blogger.com/atom/ns#" term="Query Optimization" /><category scheme="http://www.blogger.com/atom/ns#" term="Execution Plan" /><title>UNION Vs UNION ALL</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;This issue came up during one of the&amp;nbsp;training&amp;nbsp;I conducted recently. There is a popular belief that UNION will ALWAYS perform a unique filter on the data.&amp;nbsp; While it is true that UNION Clause will ALWAYS RETURN unique set of data, filtering operation either sort or distinct select is not guaranteed. &lt;br /&gt;
&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Take this example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; SalesOrderID&lt;span style="color: grey;"&gt;,&lt;/span&gt; SalesOrderDetailID&lt;span style="color: grey;"&gt;,&lt;/span&gt; OrderQty&lt;span style="color: grey;"&gt;,&lt;/span&gt; ProductID&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPrice&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPriceDiscount &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; SalesLT&lt;span style="color: grey;"&gt;.&lt;/span&gt;SalesOrderDetail &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ProductID &lt;span style="color: grey;"&gt;=&lt;/span&gt; 799&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;UNION&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; SalesOrderID&lt;span style="color: grey;"&gt;,&lt;/span&gt; SalesOrderDetailID&lt;span style="color: grey;"&gt;,&lt;/span&gt; OrderQty&lt;span style="color: grey;"&gt;,&lt;/span&gt; ProductID&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPrice&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPriceDiscount &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; SalesLT&lt;span style="color: grey;"&gt;.&lt;/span&gt;SalesOrderDetail &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ProductID &lt;span style="color: grey;"&gt;=&lt;/span&gt; 989&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; SalesOrderID&lt;span style="color: grey;"&gt;,&lt;/span&gt; SalesOrderDetailID&lt;span style="color: grey;"&gt;,&lt;/span&gt; OrderQty&lt;span style="color: grey;"&gt;,&lt;/span&gt; ProductID&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPrice&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPriceDiscount &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; SalesLT&lt;span style="color: grey;"&gt;.&lt;/span&gt;SalesOrderDetail &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ProductID &lt;span style="color: grey;"&gt;=&lt;/span&gt; 799&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;UNION&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: grey;"&gt;ALL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; SalesOrderID&lt;span style="color: grey;"&gt;,&lt;/span&gt; SalesOrderDetailID&lt;span style="color: grey;"&gt;,&lt;/span&gt; OrderQty&lt;span style="color: grey;"&gt;,&lt;/span&gt; ProductID&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPrice&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPriceDiscount &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; SalesLT&lt;span style="color: grey;"&gt;.&lt;/span&gt;SalesOrderDetail &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ProductID &lt;span style="color: grey;"&gt;=&lt;/span&gt; 989&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;The results will be unique. Irrespective of whether you use UNION or UNION ALL, the results are same. More than that, the execution plan shows that there is no sort operation involved.&lt;br /&gt;
&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-el0Rlxownwk/Tlz1EttfafI/AAAAAAAAAb4/--5vsU4YvZs/s1600/union-union+all+img1.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-el0Rlxownwk/Tlz1EttfafI/AAAAAAAAAb4/--5vsU4YvZs/s1600/union-union+all+img1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Is that mean that we do not have to worry about UNION ALL? Will SQL Server use the right choice all the time, Irrespective of whether we use UNON or UNION ALL?&amp;nbsp;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: red;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;u style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;NO!&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;There are cases where UNION ALL and UNION turns out to the same execution plan,&amp;nbsp; it is not guaranteed that the plan will be same.&amp;nbsp; For example, when some complexity is added to the script, SQL Server will not understand the uniqueness and will turn to filter the data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Consider this script:&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; SalesOrderID&lt;span style="color: grey;"&gt;,&lt;/span&gt; SalesOrderDetailID&lt;span style="color: grey;"&gt;,&lt;/span&gt; OrderQty&lt;span style="color: grey;"&gt;,&lt;/span&gt; ProductID&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPrice&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPriceDiscount &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; SalesLT&lt;span style="color: grey;"&gt;.&lt;/span&gt;SalesOrderDetail &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ProductID &lt;span style="color: grey;"&gt;=&lt;/span&gt; 799&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;UNION&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; SalesOrderID&lt;span style="color: grey;"&gt;,&lt;/span&gt; SalesOrderDetailID&lt;span style="color: grey;"&gt;,&lt;/span&gt; OrderQty&lt;span style="color: grey;"&gt;,&lt;/span&gt; ProductID&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPrice&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPriceDiscount &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; SalesLT&lt;span style="color: grey;"&gt;.&lt;/span&gt;SalesOrderDetail &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ProductID &lt;span style="color: grey;"&gt;=&lt;/span&gt; 989&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;UNION&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"&gt;&lt;span lang="EN-US"&gt;&lt;span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt; SalesOrderID&lt;span style="color: grey;"&gt;,&lt;/span&gt; SalesOrderDetailID&lt;span style="color: grey;"&gt;,&lt;/span&gt; OrderQty&lt;span style="color: grey;"&gt;,&lt;/span&gt; ProductID&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPrice&lt;span style="color: grey;"&gt;,&lt;/span&gt; UnitPriceDiscount &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; SalesLT&lt;span style="color: grey;"&gt;.&lt;/span&gt;SalesOrderDetail &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; ProductID &lt;span style="color: grey;"&gt;=&lt;/span&gt; 868&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Just an additional SELECT is added.&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-NuRg0RZ2_RY/Tlz1RaWfx5I/AAAAAAAAAb8/ttK_qVndXho/s1600/union-union+all+img2.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-NuRg0RZ2_RY/Tlz1RaWfx5I/AAAAAAAAAb8/ttK_qVndXho/s1600/union-union+all+img2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The new compiled plan is completely different. More than that, it introduces MERGE JOIN (UNION) which is used to sort and join the data, against the CONCATENATION operation in the previous query. &amp;nbsp;&lt;/div&gt;The bottom line is use UNION ALL whenever possible.&amp;nbsp; It does remove the ambiguity.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-7353593272114114149?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/14ETH44UBGJfh38mXF_hgVJGqkQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/14ETH44UBGJfh38mXF_hgVJGqkQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/14ETH44UBGJfh38mXF_hgVJGqkQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/14ETH44UBGJfh38mXF_hgVJGqkQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/87mM0KZ3aAM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/7353593272114114149/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/08/union-vs-union-all.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/7353593272114114149?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/7353593272114114149?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/87mM0KZ3aAM/union-vs-union-all.html" title="UNION Vs UNION ALL" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-el0Rlxownwk/Tlz1EttfafI/AAAAAAAAAb4/--5vsU4YvZs/s72-c/union-union+all+img1.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/08/union-vs-union-all.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkYCQH4-cSp7ImA9WhdXFU4.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-2187576070998383287</id><published>2011-08-28T16:46:00.000+05:30</published><updated>2011-08-28T16:46:01.059+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-28T16:46:01.059+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Powershell" /><title>Removing unnecessary files using powershell</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Now a days some people (including me) used to save whole heap of files into their hard disks. Word documents, excel sheets, powerpoint presentations, pictures &amp;nbsp;taken,&amp;nbsp;pictures&amp;nbsp;received from others and white papers (some times they are word documents), code files (including SQL), &amp;nbsp; Then you have Acrobat reader files, e-books, video and audio files. &amp;nbsp;Most of them take a lot of space. In addition to it, I also have multiple versions of it.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Managing the files is a problem. &amp;nbsp;Who likes the idea of losing the files due to of hardware corruption? A simple solution is to take backups. External hard disks are are cheap and handy solution for this issue.&lt;br /&gt;
I am not sure how this mechanism works for you, but for me, it is a problem. I have downloaded same documents multiple times, and each time it has gone into a different location.I have also taken backup at different stages, and some times I have removed the files from my hard disk and some times, I haven't. Now it turned out to be that &amp;nbsp;I have same files in multiple backup folders and zip files and it is a painful process to identify them one by one and delete unnecessary ones.&lt;br /&gt;
So I wrote e Powershell script, Which goes through my all backups and identify the&amp;nbsp;identical&amp;nbsp;files.&lt;br /&gt;
I hope this is useful to you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;$path&lt;/span&gt; = "l:\complete"&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue;"&gt;$d&lt;/span&gt; = get-childitem &lt;span class="Apple-style-span" style="color: blue;"&gt;$path&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt; = &lt;span class="Apple-style-span" style="color: blue;"&gt;$d&lt;/span&gt; | sort-object Name,DirectoryName&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue;"&gt;$j&lt;/span&gt; =0&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: blue;"&gt;$totalspace&lt;/span&gt; =0&lt;br /&gt;
for (&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;=0; &lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt; -lt &lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;.Length-1; &lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if ((&lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;].Name -eq &lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;+1].Name) -and (&lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;].Length -eq &lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;+1].Length))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="Apple-style-span" style="color: blue;"&gt;$line&lt;/span&gt; = "FC /B /LB1&amp;nbsp; """ +&lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;].FullName + """ &amp;nbsp;"""+ &lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;+1].FullName+""" &amp;nbsp;&amp;gt;&amp;gt;L:\Comparefiles.txt"&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="Apple-style-span" style="color: blue;"&gt;$line&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt; $j++&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="Apple-style-span" style="color: blue;"&gt;$totalspace&lt;/span&gt;+=&lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;].Length&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;/blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;"FilesFound "+ &lt;span class="Apple-style-span" style="color: blue;"&gt;$j&lt;/span&gt;+ "; totalSpace "+ &lt;span class="Apple-style-span" style="color: blue;"&gt;$totalspace&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First I compared the files using FC (File&amp;nbsp;Compare utility that comes with Windows) Later with slight modification I removed one file by moving one file to another location. it needs only one change in the script: &amp;nbsp;Change the line calls FC to call MOVE&lt;br /&gt;
&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;$line&lt;/span&gt; = "MOVE /Y """ +&lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;].FullName + """ &amp;nbsp;"""+ &lt;span class="Apple-style-span" style="color: blue;"&gt;$dd&lt;/span&gt;[&lt;span class="Apple-style-span" style="color: blue;"&gt;$i&lt;/span&gt;+1].FullName+""""&lt;/span&gt;&lt;/blockquote&gt;&amp;nbsp;The results are&amp;nbsp;copied&amp;nbsp; into a .bat file (text document&amp;nbsp;with the .bat extension) and after removing the line where you may need both files, the /bat file was executed.&lt;br /&gt;
You can further improve the code in various ways:&lt;br /&gt;
1. &amp;nbsp;You can include the files you need based on parameters and filters, &lt;br /&gt;
&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;$d&lt;/span&gt; = get-childitem &lt;span class="Apple-style-span" style="color: blue;"&gt;$path&lt;/span&gt; -include *.PDF -recurse | where-object {&lt;span class="Apple-style-span" style="color: blue;"&gt;$_&lt;/span&gt;.Length -gt 1000000}&lt;/span&gt;&lt;/blockquote&gt;2. &amp;nbsp;You can add additional commands for comparison. If you want to find the attributes you want to use, you can try,&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;$d&lt;/span&gt;[0] |select *&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;When I tried this is the answer I got:&lt;/span&gt;&lt;br /&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PSPath &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: Microsoft.PowerShell.Core\FileSystem::L:\Complete\E\Z\Other Useful Docs\SQL2K5 Install Docs\OLD\1_SQL2K5 Troubleshooting guide.doc&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PSParentPath &amp;nbsp; &amp;nbsp; &amp;nbsp;: Microsoft.PowerShell.Core\FileSystem::L:\Complete\E\Z\Other Useful Docs\SQL2K5 Install Docs\OLD&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PSChildName &amp;nbsp; &amp;nbsp; &amp;nbsp; : 1_SQL2K5 Troubleshooting guide.doc&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PSDrive &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : L&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PSProvider &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: Microsoft.PowerShell.Core\FileSystem&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;PSIsContainer &amp;nbsp; &amp;nbsp; : False&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;VersionInfo &amp;nbsp; &amp;nbsp; &amp;nbsp; : File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; L:\Complete\E\Z\Other Useful Docs\SQL2K5 Install Docs\OLD\1_SQL2K5 Troubleshooting guide.doc&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; InternalName: &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OriginalFilename:&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FileVersion: &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FileDescription: &amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Product: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ProductVersion: &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Debug: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;False&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Patched: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;False&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PreRelease: &amp;nbsp; &amp;nbsp; &amp;nbsp; False&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PrivateBuild: &amp;nbsp; &amp;nbsp; False&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SpecialBuild: &amp;nbsp; &amp;nbsp; False&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Language: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;BaseName &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 1_SQL2K5 Troubleshooting guide&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Mode &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: -a---&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 1_SQL2K5 Troubleshooting guide.doc&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Length &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: 44032&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;DirectoryName &amp;nbsp; &amp;nbsp; : L:\Complete\E\Z\Other Useful Docs\SQL2K5 Install Docs\OLD&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Directory &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : L:\Complete\E\Z\Other Useful Docs\SQL2K5 Install Docs\OLD&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;IsReadOnly &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: False&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Exists &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: True&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;FullName &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: L:\Complete\E\Z\Other Useful Docs\SQL2K5 Install Docs\OLD\1_SQL2K5 Troubleshooting guide.doc&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Extension &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : .doc&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;CreationTime &amp;nbsp; &amp;nbsp; &amp;nbsp;: 29/9/09 01:56:28 PM&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;CreationTimeUtc &amp;nbsp; : 29/9/09 08:26:28 AM&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;LastAccessTime &amp;nbsp; &amp;nbsp;: 14/10/09 06:55:56 AM&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;LastAccessTimeUtc : 14/10/09 01:25:56 AM&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;LastWriteTime &amp;nbsp; &amp;nbsp; : 27/4/07 10:04:00 PM&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;LastWriteTimeUtc &amp;nbsp;: 27/4/07 04:34:00 PM&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Attributes &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: Archive&lt;/span&gt;&lt;/blockquote&gt;&lt;div style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/blockquote&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Hope this post helps you to manage your files too:&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-2187576070998383287?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gYIekiKP6TBhZWfuWHhntQ6d9dA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gYIekiKP6TBhZWfuWHhntQ6d9dA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gYIekiKP6TBhZWfuWHhntQ6d9dA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gYIekiKP6TBhZWfuWHhntQ6d9dA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/wotyjA13Fdk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/2187576070998383287/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/08/removing-unnecessary-files-using.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/2187576070998383287?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/2187576070998383287?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/wotyjA13Fdk/removing-unnecessary-files-using.html" title="Removing unnecessary files using powershell" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/08/removing-unnecessary-files-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MMRXc7eCp7ImA9WhdXF0w.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-661047053380484933</id><published>2011-08-24T09:26:00.000+05:30</published><updated>2011-08-30T20:14:44.900+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T20:14:44.900+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Training" /><category scheme="http://www.blogger.com/atom/ns#" term="SSSLUG" /><title>Speaking again at SSSLUG</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I was scheduled to speak at this user group meeting (That's today.) I am ready with the presentation. However, after having a small hickup on some personal issues, I asked Dinesh Asanka to do it. He too was ready with the presentation, but at our office he got something. He presence was needed at office at that time. So, I am back to square one is doing the presentation.&lt;br /&gt;
I am speaking on SQL Server 2008 R2 StreamInsight. This session gives an introduction to Stream Insight.&lt;br /&gt;
by the way, we are planning to have live tweets of the session. If you are unable to come please watch the tweets Follow SqlSvrUniverse.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-661047053380484933?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qjgXnRiih5lJueKiURmaxfTGmKo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qjgXnRiih5lJueKiURmaxfTGmKo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qjgXnRiih5lJueKiURmaxfTGmKo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qjgXnRiih5lJueKiURmaxfTGmKo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/yeT6jTD-27Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/661047053380484933/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/07/speaking-again-at-ssslug.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/661047053380484933?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/661047053380484933?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/yeT6jTD-27Q/speaking-again-at-ssslug.html" title="Speaking again at SSSLUG" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/07/speaking-again-at-ssslug.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UMQX07eCp7ImA9WhdQEE8.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-8014046652702884000</id><published>2011-08-11T06:42:00.001+05:30</published><updated>2011-08-11T06:44:40.300+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-11T06:44:40.300+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Denali" /><category scheme="http://www.blogger.com/atom/ns#" term="Training" /><title>Resources on Denali</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;onYesterday, Microsoft has announced the release of&amp;nbsp;&lt;/span&gt;Product Guide v1 for&amp;nbsp;SQL Server Code Name “Denali” Community Technology Preview 3 (CTP3). This is a single download that organizes Denali related content for easier viewing. It is available for download at&amp;nbsp;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=225814" style="color: #0000cc;" target="_blank"&gt;http://go.microsoft.com/&lt;wbr&gt;&lt;/wbr&gt;fwlink/?LinkID=225814&lt;/a&gt;.&amp;nbsp;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: black;"&gt;The SQL Server Code Name “Denali” CTP3 Product Guide includes useful resources and demos that will help IT Professionals better evaluate of CTP3.&amp;nbsp; This includes:&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;14 Product Datasheets&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;8 PowerPoint Presentations&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;5 Technical White Papers&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;13 Hands-On Lab Preview Documents&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;6 Click-Through Demonstrations&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;13 Self-Running Demonstrations&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;26 Links to On-Line References&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 14px; margin-bottom: 10pt;"&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;-&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;u&gt;&lt;/u&gt;&lt;span lang="EN-US" style="color: black;"&gt;44 Links to On-Line Videos including 26 Presentations from North America TechEd 2011&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Microsoft also stated that they have a short windows of opportunity to shape the final release, so itmay be one of the rare&amp;nbsp;opportunities&amp;nbsp;to provide feedback on the features, usability and effectiveness. Microsoft expects the customers, communities and organizations&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: arial, sans-serif; font-size: 13px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US"&gt;to&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;a href="https://connect.microsoft.com/SQLServer/Feedback" style="color: #0000cc;" target="_blank"&gt;provide feedback&lt;/a&gt;&amp;nbsp;on SQL Server CTP3 release in the next 60 days.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;More to come, stay tuned.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-8014046652702884000?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3CBaueFaPIs7ABfYXS1hO09xlCw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3CBaueFaPIs7ABfYXS1hO09xlCw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3CBaueFaPIs7ABfYXS1hO09xlCw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3CBaueFaPIs7ABfYXS1hO09xlCw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/GK1-EX71Mho" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/8014046652702884000/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/08/resources-for-denali.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/8014046652702884000?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/8014046652702884000?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/GK1-EX71Mho/resources-for-denali.html" title="Resources on Denali" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/08/resources-for-denali.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUANQH8_cSp7ImA9WhdTFkw.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-4151382377397849223</id><published>2011-07-14T08:53:00.001+05:30</published><updated>2011-07-14T08:53:11.149+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-14T08:53:11.149+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Denali" /><category scheme="http://www.blogger.com/atom/ns#" term="Data Types" /><category scheme="http://www.blogger.com/atom/ns#" term="Hierarchical Data" /><category scheme="http://www.blogger.com/atom/ns#" term="Database Design" /><category scheme="http://www.blogger.com/atom/ns#" term="Powershell" /><category scheme="http://www.blogger.com/atom/ns#" term="What's New" /><title>Denali CTP3, Juneau CTP3 &amp; SQL Server 2008 R2 sp1 Available</title><content type="html">&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Let me give a different order:&lt;/p&gt; &lt;h3&gt;SQL Server 2008 R2 sp1 &lt;/h3&gt; &lt;p&gt;Yes, it is finally available.&amp;nbsp; Check out the links below.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=214356"&gt;SQL Server 2008 R2 SP1&lt;/a&gt;&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=214357"&gt;SQL Server 2008 R2 SP1 Express&lt;/a&gt;&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt; &lt;li&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=214358"&gt;SQL Server 2008 R2 SP1 Feature Packs&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;You can download the files based on the processor you have.&amp;nbsp; In addition to bug fixes some interesting enhancements too are added to this service pack. &lt;/p&gt; &lt;li&gt;&lt;b&gt;&lt;font size="2"&gt;Dynamic Management Views for increased supportability:&lt;/font&gt;&lt;/b&gt; &lt;ul&gt;&lt;font size="2"&gt;sys.dm_exec_query_stats DMV is extended with additional columns to improve supportabilities over troubleshooting long-running queries. New DMVs and XEvents on select performance counters are introduced to monitor OS configurations and resource conditions related to the SQL Server instance.&lt;/font&gt;&lt;/ul&gt; &lt;li&gt;&lt;b&gt;&lt;font size="2"&gt;FORCESEEK for improved querying performance :&lt;/font&gt;&lt;/b&gt; &lt;ul&gt;&lt;font size="2"&gt;Syntax for FORCESEEK index hint has been modified to take optional parameters allowing it to control the access method on the index even further. Using old style syntax for FORCESEEK remains unmodified and works as before. In addition to that, a new query hint, FORCESCAN has been added. It complements the FORCESEEK hint allowing specifying ‘scan’ as the access method to the index. No changes to applications are necessary if you do not plan to use this new functionality.&lt;/font&gt;&lt;/ul&gt; &lt;li&gt;&lt;b&gt;&lt;font size="2"&gt;Data-tier Application Component Framework (DAC Fx) for improved database upgrades:&lt;/font&gt;&lt;/b&gt; &lt;ul&gt;&lt;font size="2"&gt;The new Data-tier Application (DAC) Framework v1.1 and DAC upgrade wizard enable the new in-place upgrade service for database schema management. The new in-place upgrade service will upgrade the schema for an existing database in SQL Azure and the versions of SQL Server supported by DAC. A DAC is an entity that contains all of the database objects and instance objects used by an application. A DAC provides a single unit for authoring, deploying, and managing the data-tier objects. For more information, see &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=199000"&gt;&lt;font size="2"&gt;Designing and Implementing Data-tier Applications.&lt;/font&gt;&lt;/a&gt;&lt;/ul&gt; &lt;li&gt;&lt;b&gt;&lt;font size="2"&gt;Disk space control for PowerPivot:&lt;/font&gt;&lt;/b&gt; &lt;ul&gt;&lt;font size="2"&gt;This update introduces two new configuration settings that let you determine how long cached data stays in the system. In the new Disk Cache section on the PowerPivot configuration page, you can specify how long an inactive database remains in memory before it is unloaded. You can also limit how long a cached file is kept on disk before it is deleted.&lt;/font&gt;&lt;/ul&gt;&lt;/li&gt; &lt;p&gt;As you may aware, SQL Server 2008 R2 is not supported on Windows XP.&lt;/p&gt; &lt;p&gt;On feature packs, some of the cools stuffs are added.&amp;nbsp; The list below is my favourites&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;b&gt;&lt;font size="2"&gt;Report Builder 3.0 enhancements:&lt;/font&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;Additional visualizations including maps, spark lines and data bars are introduced.&amp;nbsp; It also comes with report part gallery. It means you can develop report parts and add them to the reports you want.&lt;/p&gt;&lt;/blockquote&gt; &lt;ul&gt; &lt;li&gt;&lt;b&gt;Microsoft® System CLR Types for SQL Server® 2008 R2&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;This allows the CLR based data types of SQL Server, geography, geometry and hierarchyid to be installed outside the server. By doing so, a client application can use the same data types.&amp;nbsp; &lt;/p&gt;&lt;/blockquote&gt; &lt;ul&gt; &lt;li&gt;&lt;b&gt;Microsoft® SQL Server® 2008 R2 Remote Blob Store&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;I first heard about it as part of Denali.&amp;nbsp; However, I am surprised to see it as part of feature pack.&amp;nbsp; This component allows the data to be stored in an external data store. Microsoft is providing a client side DLL and SQL Server stored procedures&lt;/p&gt;&lt;/blockquote&gt; &lt;ul&gt; &lt;li&gt;&lt;b&gt;Microsoft® Windows PowerShell Extensions for SQL Server® 2008 R2&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt; &lt;blockquote&gt; &lt;p&gt;How can I hide my joy to see something connected to PowerShell. In fact one of my favourite tools is PowerShell. It allows server administration, irrespective of whether it is Windows,&amp;nbsp; SQL Server or Exchange, through a set of cmdlets.&amp;nbsp; It eases the tasks of administrators.&amp;nbsp; I hear that a couple of new cmdlets and a new provider have beed added.&amp;nbsp; Need to have a look. &lt;/p&gt;&lt;/blockquote&gt; &lt;h3&gt;Denali CTP 3&lt;/h3&gt; &lt;p&gt;Despite some earlier announcements, CTP3 was made available to public on 12th.&amp;nbsp; Denali is the next version of SQL Server.&amp;nbsp; Earlier references said it would be released in the second half of 2011, yes we are already there.&amp;nbsp; However, Now the messages are suggesting that it will be named as SQL Server 2012 indicating the release date to end of this year, or somewhere in next year.&lt;/p&gt; &lt;p&gt;Let me warn you that you way start downloading files of 2.4 GB of size. Do you have the facility to do so? then go for. &lt;/p&gt; &lt;p&gt;Want to download? Try this link:&lt;/p&gt; &lt;p&gt;&lt;a title="https://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/" href="https://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/"&gt;https://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;I’ll write about the features of Denali on a different post.&lt;/font&gt;&lt;/p&gt; &lt;h3&gt;Juneau CTP3&lt;/h3&gt; &lt;p&gt; It gives a different user interface, to database developers. It allows Visual Studio to be used to create all database objects from table to stored procedures. People who are familiar with “Data Dude” or “Visual Studio for Database Professionals” can consider Juneau as the next generation of that. &lt;/p&gt; &lt;p&gt;There is little more on it:&amp;nbsp; You can do all design in your local machine, and deploy to SQL Server or SQL Azure. you don’t need different tools to find the changes happened, it is included in Juneau. Additionally, it all in one source control..&lt;/p&gt; &lt;p&gt;Try this link: &lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/data/hh297027"&gt;http://msdn.microsoft.com/en-us/data/hh297027&lt;/a&gt;&lt;/p&gt; &lt;p&gt;There are many more internal projects, &lt;font color="#0000ff"&gt;Apollo, Velocity, Crescent&lt;/font&gt; and many more are on the pipeline. The information we receive are exciting. Lets wait to see them too. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-4151382377397849223?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MgC77Mn9tlnjojulRoXXnEHVivI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MgC77Mn9tlnjojulRoXXnEHVivI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MgC77Mn9tlnjojulRoXXnEHVivI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MgC77Mn9tlnjojulRoXXnEHVivI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/qDVq0jvwfF4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/4151382377397849223/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/07/denali-ctp3-juneau-ctp3-sql-server-2008.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4151382377397849223?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4151382377397849223?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/qDVq0jvwfF4/denali-ctp3-juneau-ctp3-sql-server-2008.html" title="Denali CTP3, Juneau CTP3 &amp;amp; SQL Server 2008 R2 sp1 Available" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/07/denali-ctp3-juneau-ctp3-sql-server-2008.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0UNRH44eSp7ImA9WhdTFUo.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-869495645241265962</id><published>2011-07-13T21:00:00.001+05:30</published><updated>2011-07-13T21:04:55.031+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-13T21:04:55.031+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Fragmentation" /><category scheme="http://www.blogger.com/atom/ns#" term="Internals" /><category scheme="http://www.blogger.com/atom/ns#" term="Split" /><category scheme="http://www.blogger.com/atom/ns#" term="Page" /><title>Understanding Page Splits</title><content type="html">&lt;strong&gt;Note: I thought of writing about page splits. Initially I started writing a blog and it slowly became a huge article. I was having two minds on whether I should write a series, of blogs or go for a big article. Finally, I have made up my mind for the first option and here is the first part of the article. My plan is to write different aspects of page splits in coming days…&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
In SQL Server data is stored into a page. A data page is 8 kb of size. It means when the rows are inserted they need to be inserted into a page. There is an exception when large blob data is inserted sql server can insert the data separately into another page and keep only the pointer (For more details refer: row overflow). Apart from that, a row should fit into the page and cannot split into multiple pages.  &lt;br /&gt;
&lt;br /&gt;
The decision on where the data should be inserted is decided by the clustered key. The data is logically stored in clustered key order. (I’ll discuss later on why the word “logically” is used here. But it is safe to assume the order of the pages is clustered key order) When a row need to be inserted or updated but it cannot fit into the empty space, the content of the row splits into two pages (without breaking the row) and it is called page split. &lt;br /&gt;
There are primarily two reasons for it to occur:  &lt;br /&gt;
· Data inserts not in clustered key order &lt;br /&gt;
· Update of variable length columns &lt;br /&gt;
Let’s analyse each scenario: &lt;br /&gt;
Now let us assume we have a table which has a row size of 1300 bytes. It means a fully occupied page will have 6 rows. Let us assume that we have a table where a particular page has 5 rows having the clustered key values 2,4,6,8, 10 and 12. Now a new row is inserted with the clustered key of 5. It should be inserted into the same page as the value 5 falls between 4 and 6. But the page does not have space and it needs a new page. However, if the only the new row is copied into the new page, the clustered key order cannot be maintained.  &lt;br /&gt;
Now SQL server will perform the operation of page split. It will create a new page and copy half of the rows into the new page. Now both pages will be half empty, so that the new page will be inserted into the page it needs to be inserted. In this case the first page will have rows 2,4,5 and 6 and the next page will have rows 8, 10 and 12.  &lt;br /&gt;
The following code illustrates the point: &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;CREATE TABLE&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; dbo.Note&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: small; font-weight: normal;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NoteID &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; NOT NULL &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;CONSTRAINT &lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;PK_Note &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;PRIMARY KEY CLUSTERED&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; (NoteID),&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NoteText&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;varchar&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;(2000) NOT NULL&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size: small; font-weight: normal;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue; font-size: small; font-weight: normal;"&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;INSERT INTO&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; dbo.Note &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;VALUES&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;( 2,&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style="font-weight: normal;"&gt;'Some notes here.'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;INSERT INTO&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; dbo.Note &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;VALUES&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;( 4,&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style="font-weight: normal;"&gt;'Some notes here.'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;INSERT INTO&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; dbo.Note &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;VALUES&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;( 6,&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style="font-weight: normal;"&gt;'Some notes here.'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;INSERT INTO&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; dbo.Note &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;VALUES&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;( 8,&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style="font-weight: normal;"&gt;'Some notes here.'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;INSERT INTO&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; dbo.Note &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;VALUES&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;(10,&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style="font-weight: normal;"&gt;'Some notes here.'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;INSERT INTO&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt; dbo.Note &lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-weight: normal;"&gt;VALUES&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;(12,&lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style="font-weight: normal;"&gt;'Some notes here.'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;)&lt;/span&gt;&lt;/span&gt; &lt;/h3&gt;As the data is ordered on clustered key (i.e. NoteID) this will not create page split. However, when the data for the next day is inserted it will cause page split.  &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;( 5,&lt;span style="color: red;"&gt;'New notes here.'&lt;/span&gt;)&lt;/span&gt;   &lt;br /&gt;
&lt;br /&gt;
The reason for page split is it cannot hold the all the rows in the page. When a page split happens the row will be divided into two and the second half of the data will be moved into the new page. &lt;br /&gt;
There is another reason for page splits. Assume you have a variable length column in the table. Assume it is defined as varchar(2000). Since it is a variable length column, it will not occupy all 2000 bytes. Lets take this example: &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;h3&gt;&lt;span style="font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small;"&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; dbo.Note&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;(&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NoteID &lt;span style="color: blue;"&gt;int&lt;/span&gt; NOT NULL &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; PK_Note &lt;span style="color: blue;"&gt;PRIMARY KEY CLUSTERED&lt;/span&gt; (NoteID),&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NoteText &lt;span style="color: blue;"&gt;varchar&lt;/span&gt;(2000) NOT NULL&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;)&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue; font-size: small; font-weight: normal;"&gt;GO&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 1,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 2,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 3,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 4,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 5,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 6,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-weight: normal;"&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 7,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style="font-family: 'Courier New'; font-size: small; font-weight: normal;"&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt; ( 8,&lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'a'&lt;/span&gt;, 900))&lt;/span&gt;&lt;/h3&gt;Even though the NoteText is specified to have 2000 bytes, they hold only 900 bytes. Now when a row is updated with a higher length string, it may need space more than what is available.&lt;br /&gt;
&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; dbo.Note &lt;span style="color: blue;"&gt;SET&lt;/span&gt; NoteText = &lt;span style="color: magenta;"&gt;REPLICATE&lt;/span&gt;(&lt;span style="color: red;"&gt;'c'&lt;/span&gt;, 2000) &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; NoteID = 3&lt;/span&gt; &lt;br /&gt;
Since there is no space to accommodate the additional 1100 bytes, it needs a page split. Again the page is divided where the original page will have only four rows ( NoteID &amp;lt;=4) and rest will be in new page.  &lt;br /&gt;
There are couple of differences between a new page getting added and page split. &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Data growth in the order of clustered key leads to new pages getting added. But it ALWAYS happen at the end of the page. Page split refers to a page getting inserted in the middle of the list&lt;/li&gt;
&lt;li&gt;Adding new page starts with the blank page and only updates a pointer in the previous page.&amp;nbsp; When page split occurs half of the rows are getting copied into the new page.&lt;/li&gt;
&lt;/ol&gt;There are there any more reasons for page splits? Lets look it in another blog…&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-869495645241265962?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/JdbUjJLEmCSyuDPgCsNzBUiOm48/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JdbUjJLEmCSyuDPgCsNzBUiOm48/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/JdbUjJLEmCSyuDPgCsNzBUiOm48/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JdbUjJLEmCSyuDPgCsNzBUiOm48/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/8vHdJ5vY4XE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/869495645241265962/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/07/understanding-page-splits.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/869495645241265962?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/869495645241265962?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/8vHdJ5vY4XE/understanding-page-splits.html" title="Understanding Page Splits" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/07/understanding-page-splits.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0EFSHY-cSp7ImA9WhdXF0w.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-4388260451019178410</id><published>2011-05-15T23:21:00.001+05:30</published><updated>2011-08-30T20:16:59.859+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-30T20:16:59.859+05:30</app:edited><title>Speaking Again: Wait Statistics</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Yes I am back from Hibernate mode. &amp;nbsp; Due to various reasons I couldn't update my blog for four long months. A couple of my friends were repeatedly reminding me. &amp;nbsp;Now, I am starting again.&lt;br /&gt;
This month, &amp;nbsp;I am scheduled to speak about &lt;b&gt;Wait Statistics&lt;/b&gt; at SQL Server&amp;nbsp;Sri Lanka&amp;nbsp;User Group (SSSLUG). &amp;nbsp;I gave this topic somewhere in the&amp;nbsp;beginning&amp;nbsp;of this year, By I need to wait till this month to speak about wait statistics.&lt;br /&gt;
&lt;br /&gt;
Wait statistics is a key part in tracking down application and server performance issues. I believe it is very important to Server Administrators, DBAs and Developers &lt;br /&gt;
&lt;br /&gt;
Due to Vesak holidays, the meeting is postponed to next week and I am expecting an official notice soon. &lt;br /&gt;
See you all there...&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-4388260451019178410?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/99yMw5xdSnstnR7LQir3Pxvu3mc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/99yMw5xdSnstnR7LQir3Pxvu3mc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/99yMw5xdSnstnR7LQir3Pxvu3mc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/99yMw5xdSnstnR7LQir3Pxvu3mc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/002j3MQorx4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/4388260451019178410/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/05/speaking-again-wait-statistics.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4388260451019178410?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4388260451019178410?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/002j3MQorx4/speaking-again-wait-statistics.html" title="Speaking Again: Wait Statistics" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/05/speaking-again-wait-statistics.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYFR3c9eyp7ImA9Wx9QGU4.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-3313165764117581632</id><published>2011-01-02T07:05:00.000+05:30</published><updated>2011-01-02T07:05:16.963+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-02T07:05:16.963+05:30</app:edited><title>MVP Award</title><content type="html">As some of you may know,&amp;nbsp; Microsoft has sent me a new year gift.&amp;nbsp; I have been awarded with MVP status.&lt;br /&gt;
I thank all those recommended and proposed my name for this award.&amp;nbsp; this is really an encouragement to the work and service I do.&lt;br /&gt;
I was never satisfied with all the work I have done in the past. I know as a fact that there is more I can do.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-3313165764117581632?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BxnEU52Zu4t90iFJ21Vxc-sH_dA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BxnEU52Zu4t90iFJ21Vxc-sH_dA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BxnEU52Zu4t90iFJ21Vxc-sH_dA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BxnEU52Zu4t90iFJ21Vxc-sH_dA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/hkSzTrc4qeI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/3313165764117581632/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2011/01/mvp-award.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3313165764117581632?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3313165764117581632?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/hkSzTrc4qeI/mvp-award.html" title="MVP Award" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2011/01/mvp-award.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMERnkyfip7ImA9Wx9QEEo.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-6022165720589636673</id><published>2010-12-22T23:36:00.003+05:30</published><updated>2010-12-23T07:43:27.796+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-23T07:43:27.796+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Training" /><category scheme="http://www.blogger.com/atom/ns#" term="MCM" /><title>SQL Server 2008 Microsoft Certified Master (MCM) Readiness Videos</title><content type="html">Thanks to Brad McGehee. (&lt;a href="http://www.linkedin.com/profile/view?id=1401864&amp;amp;authType=name&amp;amp;authToken=x9RZ&amp;amp;trk=api*a109615*s118149*"&gt;Linkedin&lt;/a&gt;) &lt;br /&gt;
He is the one who first mentioned about this link. (or that is where I saw it)&lt;br /&gt;
When I went to the site I was able to discover some more content deep and simple.&lt;br /&gt;
Do you want to know about the internals, and like to analyze various ways of handling things, this is something great to visit.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.microsoft.com/feeds/TechNet/en-us/How-to-videos/SQL_Server_2008_Microsoft_Certified_Master_%28MCM%29_Readiness_Videos.xml"&gt;http://www.microsoft.com/feeds/TechNet/en-us/How-to-videos/SQL_Server_2008_Microsoft_Certified_Master_%28MCM%29_Readiness_Videos.xml&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-6022165720589636673?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/G5heamQRSHVJcJ-OzO4ncvgIZ0I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G5heamQRSHVJcJ-OzO4ncvgIZ0I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/G5heamQRSHVJcJ-OzO4ncvgIZ0I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G5heamQRSHVJcJ-OzO4ncvgIZ0I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/gKGZnO5ICS8" height="1" width="1"/&gt;</content><link rel="related" href="http://www.microsoft.com/feeds/TechNet/en-us/How-to-videos/SQL_Server_2008_Microsoft_Certified_Master_%28MCM%29_Readiness_Videos.xml" title="SQL Server 2008 Microsoft Certified Master (MCM) Readiness Videos" /><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/6022165720589636673/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/12/sql-server-2008-microsoft-certified.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/6022165720589636673?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/6022165720589636673?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/gKGZnO5ICS8/sql-server-2008-microsoft-certified.html" title="SQL Server 2008 Microsoft Certified Master (MCM) Readiness Videos" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/12/sql-server-2008-microsoft-certified.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4ASHkzeSp7ImA9Wx9TEEg.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-4756291181957283735</id><published>2010-11-18T10:39:00.000+05:30</published><updated>2010-11-18T10:39:09.781+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-18T10:39:09.781+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Training" /><category scheme="http://www.blogger.com/atom/ns#" term="SSSLUG" /><category scheme="http://www.blogger.com/atom/ns#" term="Physical Join Operators" /><category scheme="http://www.blogger.com/atom/ns#" term="Scan" /><category scheme="http://www.blogger.com/atom/ns#" term="Query Optimization" /><category scheme="http://www.blogger.com/atom/ns#" term="Execution Plan" /><category scheme="http://www.blogger.com/atom/ns#" term="Seek" /><title>I am speaking today at SSSLUG on Excution Plans</title><content type="html">Today the sessions include an introduction to Denali and the second part of Execution Plans Explained. Today's session focuses on specific items in the execution plan:&amp;nbsp; Seeks, Scans and Physical Join operators.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_HtS4FZcdL4Y/TOS0ey4W0SI/AAAAAAAAAPw/K-RBJmR1CTQ/s1600/Invite_SSSLUG_201011_November2010_Meetup.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="503" src="http://4.bp.blogspot.com/_HtS4FZcdL4Y/TOS0ey4W0SI/AAAAAAAAAPw/K-RBJmR1CTQ/s640/Invite_SSSLUG_201011_November2010_Meetup.PNG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-4756291181957283735?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/LTNlo_I9HbNLEidHib1NWO9ttsE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LTNlo_I9HbNLEidHib1NWO9ttsE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/LTNlo_I9HbNLEidHib1NWO9ttsE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/LTNlo_I9HbNLEidHib1NWO9ttsE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/Or0rDbIE9e0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/4756291181957283735/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/11/i-am-speaking-today-at-ssslug-on.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4756291181957283735?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4756291181957283735?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/Or0rDbIE9e0/i-am-speaking-today-at-ssslug-on.html" title="I am speaking today at SSSLUG on Excution Plans" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_HtS4FZcdL4Y/TOS0ey4W0SI/AAAAAAAAAPw/K-RBJmR1CTQ/s72-c/Invite_SSSLUG_201011_November2010_Meetup.PNG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/11/i-am-speaking-today-at-ssslug-on.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUADRHg4fyp7ImA9Wx9TEEw.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-3188843692443216621</id><published>2010-11-17T22:39:00.000+05:30</published><updated>2010-11-17T22:39:35.637+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-17T22:39:35.637+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ALTER TABLE" /><category scheme="http://www.blogger.com/atom/ns#" term="DROPping and ADDing COLUMN" /><title>Bug? - Multiple drop and add columns can cause error</title><content type="html">This issue was first reported by my friend and colleague at eCollege Tim Sesst. We did a lot of research on this. Dinesh Asanka, Susantha and I really got into this.&amp;nbsp; Initially we thought this as a feature, but it took some time for us to understand the issue. Now we feel that it is a bug.&lt;br /&gt;
&lt;br /&gt;
Before going any further, check this code: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;IF&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: magenta; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;'TestAlterTable'&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;)&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;IS&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;NOT&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;NULL&lt;/span&gt;&lt;br /&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;DROP&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;TABLE&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; TestAlterTable&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;create&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;table&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; dbo&lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;TestAlterTable&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Id &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;identity&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;not&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;null&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;CONSTRAINT &lt;span style="color: black;"&gt;PK_TestAlterTable&lt;/span&gt; PRIMARY KEY &lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;CLUSTERED&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;col1 &lt;span style="color: blue;"&gt;char&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;8000&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: grey;"&gt;not&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: grey;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;,&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;col2 &lt;span style="color: blue;"&gt;char&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;49&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: grey;"&gt;not&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: grey;"&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;go&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;Declare&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; @i &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;int&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;While&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; @i &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;100&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;begin&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;print&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; @i&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;IF&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: magenta; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;'DF_Col2'&lt;/span&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;)&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;IS&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;NOT&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;NULL&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;ALTER&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;TABLE&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; dbo&lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;TestAlterTable &lt;span style="color: blue;"&gt;DROP&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt;&lt;b&gt; DF_COl2&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;Alter&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;table&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; dbo&lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;TestAlterTable &lt;span style="color: blue;"&gt;Drop&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: blue;"&gt;Column&lt;/span&gt;&lt;b&gt; Col2&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;Alter&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;table&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; dbo&lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;TestAlterTable &lt;span style="color: blue;"&gt;add&lt;/span&gt;&lt;b&gt; Col2 &lt;/b&gt;&lt;span style="color: blue;"&gt;char&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;49&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: grey;"&gt;NOT&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt;&lt;b&gt; DF_Col2 &lt;/b&gt;&lt;span style="color: blue;"&gt;DEFAULT&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'a'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;set&lt;/span&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt; @i&lt;/span&gt;&lt;/b&gt;&lt;span style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;+=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;"&gt;end&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Based on the number of columns and the data types you have, at one point,&amp;nbsp; you may receive an error similar too this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: x-small;"&gt;&lt;span style="color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.Net SqlClient Data Provider: Msg 1701, Level 16, State 1, Line 9&lt;/span&gt;&lt;br style="color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Creating or altering table 'TestAlterTable' failed because the minimum row size would be 8061, including 8 bytes of internal overhead. This exceeds the maximum allowable table row size of 8060 bytes.&lt;/span&gt;&lt;br style="color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;The number of times you need to drop and add columns depend totally on number of columns and data types used.&amp;nbsp;&lt;br /&gt;
Initially we thought that this was due to cleaning of data of the dropped columns from data pages.&amp;nbsp; Like the ghost entries, (where the row is deleted logically, but the data is still there in the data page) I was even prepared to name this action as &lt;b&gt;ghost columns&lt;/b&gt; but, sorry, I was wrong. This happens at the meta data level.&lt;br /&gt;
&lt;br /&gt;
Still we haven;t figured out the reason behind this.&amp;nbsp; But based on our research, it has all the behaviors of a bug. It does not happen at the first time.&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Interestingly, if you rebuild the primary key, you can continue on the same path for another fixed number of times.&lt;br /&gt;
&lt;br /&gt;
If anyone knows a good reason to say, why this is not a bug, please let me know. &lt;br /&gt;
Thanks to all the guys at eCollege who worked on this.&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-3188843692443216621?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2zOy0bYVzJ0Yi8rJcdTmfizNecI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2zOy0bYVzJ0Yi8rJcdTmfizNecI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2zOy0bYVzJ0Yi8rJcdTmfizNecI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2zOy0bYVzJ0Yi8rJcdTmfizNecI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/UXXhgQtBqQc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/3188843692443216621/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/11/bug-multiple-drop-and-add-columns-can.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3188843692443216621?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3188843692443216621?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/UXXhgQtBqQc/bug-multiple-drop-and-add-columns-can.html" title="Bug? - Multiple drop and add columns can cause error" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/11/bug-multiple-drop-and-add-columns-can.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8FR3gzeSp7ImA9Wx5aE0w.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-9169378338528037691</id><published>2010-11-09T21:12:00.016+05:30</published><updated>2010-11-09T21:20:16.681+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-09T21:20:16.681+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Index maintenance" /><category scheme="http://www.blogger.com/atom/ns#" term="index fragmentation" /><category scheme="http://www.blogger.com/atom/ns#" term="Performance Optimization" /><category scheme="http://www.blogger.com/atom/ns#" term="dm_db_index_physical_stats" /><category scheme="http://www.blogger.com/atom/ns#" term="Index" /><title>Index Remained Fragmented EVEN AFTER Index Rebuild Job</title><content type="html">I had an interesting thing to find out this week. An Organization had an issue:  Their queries are running extremely slow. They did some research on this.  They found that even simple queries which uses  index seek too are extremely slow. They copied the data into another database and created the indexes and executed again.  They were quite fast.  There were no other processes running when this test was carried out.&lt;br /&gt;
&lt;br /&gt;
Through another friend of mine they got my contacts and they called me. I got the execution plans from both databases and they were identical.  Then with the help from them, I ran a query using sys.dm_db_index_physical_stats  against this index and found that it is fragmented. They rebuilt the index  and the query started working well again. &lt;br /&gt;
&lt;br /&gt;
Using the same DMV against other tables, I found out that the indexes are fragmented. They sent me the figures they received using dm_db_index_physical_stats Fragmented means some are 80% - 95% fragmented.  To be honest with you, I even saw a few indexes showing 100% fragmentation which I have never seen before. I asked them to rebuild the indexes. Later I explained them how these house keeping jobs could be automated.&lt;br /&gt;
&lt;br /&gt;
After a couple of weeks, they called me again.  The indexes are fragmented again.  I asked them whether they have added the index maintenance job.  They answered back saying they have an index maintenance task as part of the database maintenance job and even made it as the first task of the job, [which runs on Sunday nights] but that has not resolved the issue.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
First of all I asked them whether there is any other huge process like ETL job running afterwards.  They politly said, that the index maintenance task is just part of the database maintenance task and they don’t do any other tasks in the nights. They do other things, like backing up database and executing few DBCC commands as part of the database maintenance jobs&lt;br /&gt;
&lt;br /&gt;
I was clueless. I just tried another blind shot.  I asked another question to run the physical stats on Monday morning to see the results.  When they came back with the results, it showed like the rebuild index didn’t make any improvement.&lt;br /&gt;
&lt;br /&gt;
I lost my patience.  Is this step enabled?  I even logged into their system (with the permission from their management) and checked the job.  Yes it is.  Then what is going wrong?&lt;br /&gt;
While checking I just checked the other jobs too.  There I found the issue.  The last step of the job was Shrink database.  I remembered this basically a major re-organizing event.  I moves the data/index pages drastically.&lt;br /&gt;
&lt;br /&gt;
Is this the cause for the issue?&lt;br /&gt;
&lt;br /&gt;
My tests on a different server showed me that shrinking the database could cause fragmentation of indexes.   Additionally,  I was able to get some blogs too on this subject.  The best blog I got was this:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/06/13/629059.aspx"&gt;http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/06/13/629059.aspx&lt;br /&gt;
&lt;/a&gt;&lt;br /&gt;
One paragraph says this:&lt;br /&gt;
&lt;blockquote&gt;&lt;div style="text-align: left;"&gt;“Shrinking a database file moves pages from the end of the allocated range of a database file to somewhere at the front of the file, below the shrink threshold. It pays no attention to any index ordering or potential fragmentation. Hence, shrink operations on data files are excellent ways to introduce significant logical fragmentation.”&lt;/div&gt;&lt;/blockquote&gt;When you read this paragraph, if you think this clearly says the issue, you should read the next line:&lt;br /&gt;
&lt;blockquote&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;“I've seen people who's maintenance plans are a nightly rebuild of all indexes, followed by a database shrink - total waste of time!”&lt;/b&gt;&lt;/span&gt;&lt;/blockquote&gt;I disabled the shrink database task.  Even though it took some time to understand the issue, it is a good learning for me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-9169378338528037691?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8ApTZWO8o9PCJj_S1GqnDH6omvY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8ApTZWO8o9PCJj_S1GqnDH6omvY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8ApTZWO8o9PCJj_S1GqnDH6omvY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8ApTZWO8o9PCJj_S1GqnDH6omvY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/07nwQkUPBco" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/9169378338528037691/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/11/index-remained-fragmented-even-after.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/9169378338528037691?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/9169378338528037691?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/07nwQkUPBco/index-remained-fragmented-even-after.html" title="Index Remained Fragmented EVEN AFTER Index Rebuild Job" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/11/index-remained-fragmented-even-after.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUUGRX44eCp7ImA9Wx5bFks.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-512985745955682951</id><published>2010-11-02T08:37:00.000+05:30</published><updated>2010-11-02T08:37:04.030+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-02T08:37:04.030+05:30</app:edited><title>Red gate labs</title><content type="html">Red gate has opened its lab for public viewing!&lt;br /&gt;
&lt;br /&gt;
It is web site, where the tools developed are available for download. They include &lt;br /&gt;
Log Shipping Monitor, SQL Backup to MTF Converter (which converts a red-gate backup to native SQL Server backup and Red Gate Snapper (that allows you to create SQL Compare snapshot files for SQL Server databases). &lt;br /&gt;
&lt;br /&gt;
The lab does include tools for .Net developers. Red Gate Memory Tracker (analyzing application memory usage, including loaded libraries, system heap memory and .NET memory) and Diagnostic Tool (used to collect useful system information) will help serious developers.&lt;br /&gt;
&lt;br /&gt;
These are tiny tools, which i believe Red-gate may include or have included with their products. Now these tools come as free downloads.  &lt;br /&gt;
I haven't tested all the applications yet, (in fact I haven't tested any of them) but I feel that most of them are really useful.&lt;br /&gt;
&lt;br /&gt;
Try this link&lt;br /&gt;
&lt;a href="http://labs.red-gate.com/"&gt;http://labs.red-gate.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-512985745955682951?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6fGLHz3B06Fx6KiU36dUVGAr4qc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6fGLHz3B06Fx6KiU36dUVGAr4qc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6fGLHz3B06Fx6KiU36dUVGAr4qc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6fGLHz3B06Fx6KiU36dUVGAr4qc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/7fDP66tbyTs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/512985745955682951/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/11/red-gate-labs.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/512985745955682951?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/512985745955682951?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/7fDP66tbyTs/red-gate-labs.html" title="Red gate labs" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/11/red-gate-labs.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8NRH08fyp7ImA9Wx5UGE0.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-3830056763474044234</id><published>2010-10-22T22:42:00.002+05:30</published><updated>2010-10-23T09:54:55.377+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-23T09:54:55.377+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Recompilation" /><category scheme="http://www.blogger.com/atom/ns#" term="Dynamic SQL" /><category scheme="http://www.blogger.com/atom/ns#" term="Query Optimization" /><category scheme="http://www.blogger.com/atom/ns#" term="Execution Plan" /><title>NO Recompilations when (parameter) values are different</title><content type="html">Please read another post on this subject by Dinesh Priyankara. &lt;br /&gt;
&lt;a href="http://dinesql.blogspot.com/2010/10/do-we-need-to-recompile-stored.html"&gt;http://dinesql.blogspot.com/2010/10/do-we-need-to-recompile-stored.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This is another topic came in the last user group meeting:&amp;nbsp; &lt;br /&gt;
Does SQL Server generate a new plan (in other word recompile) the query if the parameter value is changed?&lt;br /&gt;
The actual answer is it depends:&lt;br /&gt;
First of all, SQL Server does not go through the recompilation process simply because the parameter is changed. &lt;br /&gt;
As I mentioned in the previous blog, there are only certain conditions where an existing execution plan is thrown away and a new plan is used. &lt;br /&gt;
&lt;br /&gt;
Even though in my example, a new plan is created between these two statements, the value is not the cause.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DBCC FREEPROCCACHE&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;GO &lt;/div&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;* &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;Sales.SalesOrderDetail &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;WHERE &lt;/span&gt;SalesOrderDetailID &amp;lt;= 1&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;GO&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; * &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;Sales.SalesOrderDetail &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;WHERE &lt;/span&gt;SalesOrderDetailID &amp;lt;= 1000&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;GO&lt;/span&gt; &lt;/div&gt;When I ran the queries and captures the SQL:Recompile event, nothing was captured.  Interestingly, ShowPlan XML for Query Compilation too, didn't give any number as the reason for recompilation. For me it looked like SQL Server didn't consider them as same query. &lt;br /&gt;
I removed the GO statement in between and tried too.  The result was same. (except the column line number showed 1 and 2 instead of 1 always.&lt;br /&gt;
The image is attached.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMG8njyrP7I/AAAAAAAAAO8/I4_9lAQqHyQ/s1600/Profiler+1.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMG8njyrP7I/AAAAAAAAAO8/I4_9lAQqHyQ/s1600/Profiler+1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Fortunately, SQL Server provides a few DMVs (dynamic management views) which allows us to check the execution plans&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;usecounts, cacheobjtype, objtype, text &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;FROM &lt;/span&gt;&lt;span style="color: #38761d;"&gt;sys.dm_exec_cached_plans &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: magenta;"&gt;CROSS APPLY&lt;/span&gt; &lt;span style="color: #38761d;"&gt;sys.dm_exec_sql_text&lt;/span&gt;(plan_handle) &lt;/div&gt;&lt;br /&gt;
So I did the test again.&lt;br /&gt;
First I cleared the procedure cache by issuing&lt;br /&gt;
&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DBCC FREEPROCCACHE&lt;/div&gt;&lt;br /&gt;
Then I removed the GO command in between the statement and executed the two select statements in one batch followed by query on DMV.&amp;nbsp; Both statements were combined into a single query in the cached plan.&lt;br /&gt;
Then I added the GO statement and then executed again. &lt;br /&gt;
I saw an interesting thing.&amp;nbsp; instead of showing one query, it shows two queries. and each has it's own plan.&amp;nbsp; Additionally all statements were categorized as ad-hoc statements.&amp;nbsp; The prepared statement was missing.&amp;nbsp; &amp;nbsp; &lt;br /&gt;
That means, parametrization didn't identify both queries as same.&amp;nbsp; &lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_HtS4FZcdL4Y/TMG_deRwecI/AAAAAAAAAPA/z7N8T5T9T9k/s1600/Results+1.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_HtS4FZcdL4Y/TMG_deRwecI/AAAAAAAAAPA/z7N8T5T9T9k/s1600/Results+1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;I know that my computer uses simple parametrization. So I went ahead and change the setting to force parameterization.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ALTER DATABASE &lt;span style="color: black;"&gt;AdventureWorks &lt;/span&gt;SET PARAMETERIZATION FORCED&lt;/div&gt;&lt;br /&gt;
This time I found out that the ad-hoc query started using the same execution plan.&lt;br /&gt;
&lt;br /&gt;
Not only that, I also saw a new plan for the prepared statement with parametrized query.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMHCC481OFI/AAAAAAAAAPE/2WJ7Hx-MnD4/s1600/Results+2.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMHCC481OFI/AAAAAAAAAPE/2WJ7Hx-MnD4/s1600/Results+2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;Finally, I was able to learn something new. Even if your parameter values are totally different, SQL Server will not take that as a reason to recompile the query.&lt;br /&gt;
I was thinking that it was reusing the plan by looking at the query test of the execution plan.&amp;nbsp; Both queries, not only returned the same text, but also replaced the value 1 and 1000 in @1.&amp;nbsp; I assumed that SQL Server has identified them as parameters.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_HtS4FZcdL4Y/TMHFW9Ed7eI/AAAAAAAAAPM/wWvGHta6Eko/s1600/The+Execution+plan.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_HtS4FZcdL4Y/TMHFW9Ed7eI/AAAAAAAAAPM/wWvGHta6Eko/s1600/The+Execution+plan.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;
So, its time to learn something new. Even if the execution plan shows something don't trust it.&amp;nbsp; Use different queries and confirm. &amp;nbsp; &lt;br /&gt;
&lt;b&gt;Thank you Dinesh for showing me something to learn.&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-3830056763474044234?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2s-tI8sdRzZZQXmzRAYiGZqC6LM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2s-tI8sdRzZZQXmzRAYiGZqC6LM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2s-tI8sdRzZZQXmzRAYiGZqC6LM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2s-tI8sdRzZZQXmzRAYiGZqC6LM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/M-9A-12Wyf8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/3830056763474044234/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/10/no-recompilations-when-parameter-values.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3830056763474044234?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/3830056763474044234?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/M-9A-12Wyf8/no-recompilations-when-parameter-values.html" title="NO Recompilations when (parameter) values are different" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMG8njyrP7I/AAAAAAAAAO8/I4_9lAQqHyQ/s72-c/Profiler+1.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/10/no-recompilations-when-parameter-values.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4BRnczfyp7ImA9Wx5UGE0.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-1958430017671466610</id><published>2010-10-21T17:29:00.003+05:30</published><updated>2010-10-23T09:55:57.987+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-23T09:55:57.987+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Recompilation" /><category scheme="http://www.blogger.com/atom/ns#" term="Dynamic SQL" /><category scheme="http://www.blogger.com/atom/ns#" term="Query Optimization" /><category scheme="http://www.blogger.com/atom/ns#" term="Execution Plan" /><title>Recompilations after index creation</title><content type="html">Yesterday I got an interesting question:  Does adding an index to a table force the execution plans to be recreated?&lt;br /&gt;
Books online says this: &lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMAAQKX75WI/AAAAAAAAAOo/ccSNmp6XsVA/s1600/Execution+Plans+1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMAAQKX75WI/AAAAAAAAAOo/ccSNmp6XsVA/s1600/Execution+Plans+1.bmp" /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;
&lt;/div&gt;Please note the first, second and fourth bulleted points.&lt;br /&gt;
&lt;br /&gt;
It says either a structure should be changed or index used by the query should be changed. In other words not any change in the index will not force recompile.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Books online also lists at least 11 scenarios where a recompile could occur.  They are listed on the same article. As you may know, we can capture recompile event using profiler. SP:Recompile and SQL:StmtRecompile events could be used to capture it. These events have EventSubClass which represents the reason for recompile. These are the reasons.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Schema changed.&lt;/li&gt;
&lt;li&gt;Statistics changed.&lt;/li&gt;
&lt;li&gt;Deferred compile.&lt;/li&gt;
&lt;li&gt;SET option changed.&lt;/li&gt;
&lt;li&gt;Temporary table changed.&lt;/li&gt;
&lt;li&gt;Remote rowset changed.&lt;/li&gt;
&lt;li&gt;FOR BROWSE permission changed.&lt;/li&gt;
&lt;li&gt;Query notification environment changed.&lt;/li&gt;
&lt;li&gt;Partitioned view changed.&lt;/li&gt;
&lt;li&gt;Cursor options changed.&lt;/li&gt;
&lt;li&gt;OPTION (RECOMPILE) requested.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
As you may have noticed any structural changes to a table force all execution plans for depending tables to be marked as invalid. At the next execution of the code, the execution plan will be recreated.  It may even come up with the same execution plan.&lt;br /&gt;
Interestingly, event sub class does not show anything connected to indexes. Now the question is does SQL Server consider a change in index as structural change? &lt;br /&gt;
So I decided to perform a test on this. This is my plan.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Get a query which uses a clustered index scan due to unavailability of index&lt;/li&gt;
&lt;li&gt;Create the index and see whether it forces the execution plan to recompile&lt;/li&gt;
&lt;li&gt;Create a completely unrelated index on the same table and see whether it forces recompile of the query.&lt;/li&gt;
&lt;li&gt;I need to perform this for ad-hoc queries and stored procedures&lt;/li&gt;
&lt;/ul&gt;While the above tests are performed I monitored SP:Recompile and SQL:StmtRecompile events&lt;br /&gt;
&lt;br /&gt;
USE AdventureWorks;&lt;br /&gt;
EXEC sp_helpindex 'sales.SalesOrderHeader'&lt;br /&gt;
--  TerritoryID, ContactID columns are not indexed&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
Now I created the stored procedure named Get_SalesHeader_ByTerritoryID. I will use the same query with the same parameter for all the tests. &lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_HtS4FZcdL4Y/TMAA4E3fVwI/AAAAAAAAAOw/hOsgxBlBsok/s1600/base+code.bmp" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="328" src="http://4.bp.blogspot.com/_HtS4FZcdL4Y/TMAA4E3fVwI/AAAAAAAAAOw/hOsgxBlBsok/s640/base+code.bmp" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Then I opened SQL Profiler and create a new trace event. (For this test, using profiler window to capture the data may be okay, but if you are using a busy system it is recommended to use server side trace.)&lt;br /&gt;
I selected the following events and columns:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Showplan XML for Query Compile (TextData, SPID)&lt;/li&gt;
&lt;li&gt;SP: Completed (TextData,SPID)&lt;/li&gt;
&lt;li&gt;SP:Recompile (TextData, SPID , EventSubClass)&lt;/li&gt;
&lt;li&gt;SQL: BatchCompleted (TextData, SPID)&lt;/li&gt;
&lt;li&gt;SQL:StmtRecmpile (TextData, SPID,EventSubClass)&lt;/li&gt;
&lt;/ul&gt;Before starting the test, let us understand what these events are&lt;br /&gt;
SP: Recompile is fired when either an entire procedure or an individual statement is recompiled. SQL:StmtRecompile is fired when an ad-hoc SQL statement is fired. (EXEC &lt;procedure&gt; too could be considered as an ad-hoc statement)   Showplan XML for Query Compile is fired only when query is compiled and it shows the execution plan)&lt;br /&gt;
These events will help me to identify the not only the recompile events, but also the new execution plans.&lt;br /&gt;
I wrote the following script to perform the tests.&lt;br /&gt;
&lt;/procedure&gt;&lt;br /&gt;
&lt;blockquote&gt;use AdventureWorks;&lt;br /&gt;
exec sp_helpindex 'sales.SalesOrderHeader'&lt;br /&gt;
--  TerritoryID, ContactID columns are not indexed&lt;br /&gt;
go&lt;br /&gt;
USE [AdventureWorks]&lt;br /&gt;
GO&lt;br /&gt;
SET ANSI_NULLS, QUOTED_IDENTIFIER ON&lt;br /&gt;
GO&lt;br /&gt;
CREATE PROCEDURE [dbo].[Get_SalesHeader_ByTerritoryID]&lt;br /&gt;
(&lt;br /&gt;
@TerritoryID int&lt;br /&gt;
)&lt;br /&gt;
AS&lt;br /&gt;
SELECT SalesOrderID &lt;br /&gt;
FROM Sales.SalesOrderHeader&lt;br /&gt;
WHERE TerritoryID = @TerritoryID &lt;br /&gt;
&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
DBCC FREEPROCCACHE&lt;br /&gt;
GO&lt;br /&gt;
SELECT SalesOrderID FROM Sales.SalesOrderHeader WHERE TerritoryID =5&lt;br /&gt;
go&lt;br /&gt;
CREATE INDEX IX_SalesOrderHeader_TerritoryID on Sales.SalesOrderHeader(TerritoryID)&lt;br /&gt;
go&lt;br /&gt;
SELECT SalesOrderID FROM Sales.SalesOrderHeader WHERE TerritoryID =5&lt;br /&gt;
go&lt;br /&gt;
DROP INDEX Sales.SalesOrderHeader.IX_SalesOrderHeader_TerritoryID&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
DBCC FREEPROCCACHE&lt;br /&gt;
GO&lt;br /&gt;
SELECT SalesOrderID FROM Sales.SalesOrderHeader WHERE TerritoryID =5&lt;br /&gt;
go&lt;br /&gt;
CREATE INDEX IX_SalesOrderHeader_ContactID on Sales.SalesOrderHeader(ContactID)&lt;br /&gt;
go&lt;br /&gt;
SELECT SalesOrderID FROM Sales.SalesOrderHeader WHERE TerritoryID =5&lt;br /&gt;
go&lt;br /&gt;
DROP INDEX Sales.SalesOrderHeader.IX_SalesOrderHeader_ContactID&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DBCC FREEPROCCACHE&lt;br /&gt;
GO&lt;br /&gt;
EXEC Get_SalesHeader_ByTerritoryID @TerritoryID = 5&lt;br /&gt;
go&lt;br /&gt;
CREATE INDEX IX_SalesOrderHeader_TerritoryID on Sales.SalesOrderHeader(TerritoryID)&lt;br /&gt;
go&lt;br /&gt;
EXEC Get_SalesHeader_ByTerritoryID @TerritoryID = 5&lt;br /&gt;
go&lt;br /&gt;
DROP INDEX Sales.SalesOrderHeader.IX_SalesOrderHeader_TerritoryID&lt;br /&gt;
GO&lt;br /&gt;
&lt;br /&gt;
DBCC FREEPROCCACHE&lt;br /&gt;
GO&lt;br /&gt;
EXEC Get_SalesHeader_ByTerritoryID @TerritoryID = 5&lt;br /&gt;
go&lt;br /&gt;
CREATE INDEX IX_SalesOrderHeader_ContactID on Sales.SalesOrderHeader(ContactID)&lt;br /&gt;
go&lt;br /&gt;
EXEC Get_SalesHeader_ByTerritoryID @TerritoryID = 5&lt;br /&gt;
GO&lt;br /&gt;
DROP INDEX Sales.SalesOrderHeader.IX_SalesOrderHeader_ContactID&lt;br /&gt;
GO&lt;/blockquote&gt;&lt;br /&gt;
Here are the results:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_HtS4FZcdL4Y/TMAA5wPyPOI/AAAAAAAAAO0/y68GIQRXz04/s1600/results1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="384" src="http://4.bp.blogspot.com/_HtS4FZcdL4Y/TMAA5wPyPOI/AAAAAAAAAO0/y68GIQRXz04/s640/results1.bmp" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;The above results are for ad-hoc queries.&amp;nbsp; The results below show the behavior for stored procedures.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;img border="0" height="384" src="http://3.bp.blogspot.com/_HtS4FZcdL4Y/TMAA2lxsFnI/AAAAAAAAAOs/s6OlWzI-2ws/s640/results2.bmp" width="640" /&gt;&amp;nbsp;&lt;/div&gt;It shows that irrespective of whether it is a stored procedure or ad-hoc query, the results are identical. Not only that, Irrespective of whether the index created is useful for the query or not, the recompile event occurred and a new plan is created.  If the new index is found to be useful for the query a new plan is created. Otherwise the same plan is created again.&lt;br /&gt;
Another point to note is, the recompile event occurs because SQL Server considers an index creation as part of schema change. (Refer the event sub class value for the changes)&lt;br /&gt;
This may be another place for Microsoft to change in books online.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-1958430017671466610?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/M9NK9Jh-I7yffrL9dMCaQmOe-e0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/M9NK9Jh-I7yffrL9dMCaQmOe-e0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/M9NK9Jh-I7yffrL9dMCaQmOe-e0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/M9NK9Jh-I7yffrL9dMCaQmOe-e0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/1X0I67h_FJY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/1958430017671466610/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/10/recompilations-after-index-creation.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/1958430017671466610?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/1958430017671466610?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/1X0I67h_FJY/recompilations-after-index-creation.html" title="Recompilations after index creation" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_HtS4FZcdL4Y/TMAAQKX75WI/AAAAAAAAAOo/ccSNmp6XsVA/s72-c/Execution+Plans+1.bmp" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/10/recompilations-after-index-creation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0YMQn49cCp7ImA9Wx5UFU4.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-1226283425120223029</id><published>2010-10-20T07:05:00.001+05:30</published><updated>2010-10-20T07:16:23.068+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-20T07:16:23.068+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SSSLUG" /><title>Today I will be speaking at the user group meeting</title><content type="html">As some of you know, SS SLUG (SQL Server Sri Lanka User Group) meets today. Generally we have two topics to discuss.&amp;nbsp; &lt;br /&gt;
According to the plan we had earlier, I will be in the panel of the second topic (database design)&lt;br /&gt;
But due to certain unforeseen issues, at the last minute, I accepted the challenge to speak at today's user group meeting. That means I will speak on execution plans first and then will be in the panel for the second topic too.&lt;br /&gt;
&lt;br /&gt;
If everything goes well with the plan, In today's presentation, I will talk about reading execution plan, various table and index operations, and the logic behind it. At the end of the session, I expect the users to guess the execution plan for simple queries &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See you there!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-1226283425120223029?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/yEBsRlHTnOcN0Wvex9VZbic0hlk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yEBsRlHTnOcN0Wvex9VZbic0hlk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/yEBsRlHTnOcN0Wvex9VZbic0hlk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yEBsRlHTnOcN0Wvex9VZbic0hlk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/dkzJ3klU1uM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/1226283425120223029/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/10/today-i-am-speaking-at-user-group.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/1226283425120223029?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/1226283425120223029?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/dkzJ3klU1uM/today-i-am-speaking-at-user-group.html" title="Today I will be speaking at the user group meeting" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/10/today-i-am-speaking-at-user-group.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cGQ30yeCp7ImA9Wx5UFU4.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-4543147057327064143</id><published>2010-07-28T00:06:00.014+05:30</published><updated>2010-10-20T07:13:42.390+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-20T07:13:42.390+05:30</app:edited><title>Trigger Happy at SSSLUG</title><content type="html">Hope you were there at the last user group meeting!&lt;br /&gt;
&lt;br /&gt;
I was talking about triggers.&amp;nbsp; This was a beginner level session.&lt;br /&gt;
The code samples and the slide deck are uploaded at SSLUG.&amp;nbsp; you ncan download them from here:&lt;br /&gt;
&lt;a href="http://sqlserveruniverse.com/v2/SSSLUG/Downloads.aspx"&gt;http://sqlserveruniverse.com/v2/SSSLUG/Downloads.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-4543147057327064143?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KpqESaTWM1oIiNTj6l1jgC4wLgo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KpqESaTWM1oIiNTj6l1jgC4wLgo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KpqESaTWM1oIiNTj6l1jgC4wLgo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KpqESaTWM1oIiNTj6l1jgC4wLgo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/0W1fIITJwLc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/4543147057327064143/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/07/trigger-happy-at-ssslug.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4543147057327064143?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/4543147057327064143?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/0W1fIITJwLc/trigger-happy-at-ssslug.html" title="Trigger Happy at SSSLUG" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/07/trigger-happy-at-ssslug.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8DRHs8fyp7ImA9WxFUEU4.&quot;"><id>tag:blogger.com,1999:blog-12327506.post-6244293668263263829</id><published>2010-06-20T10:15:00.004+05:30</published><updated>2010-06-21T22:17:55.577+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-21T22:17:55.577+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Security" /><category scheme="http://www.blogger.com/atom/ns#" term="REVOKE" /><category scheme="http://www.blogger.com/atom/ns#" term="GRANT" /><category scheme="http://www.blogger.com/atom/ns#" term="DENY" /><category scheme="http://www.blogger.com/atom/ns#" term="Authorization" /><title>Understanding REVOKE</title><content type="html">This is one of the topics I was planning to write for a long time, but failed due to various reasons (and without valid reasons) So, this may sound too basic for some people; if so, please forgive me. I have seen much confusion over REVOKE statement. Some believe that revoke is a different word for DENY. As explaining the security model is worth a series of articles, in this post, I am going to explain only about REVOKE statement.  For this, I am using AdventureWorks database. I created two logins which I am using throughout the post&lt;br /&gt;
&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;CREATE LOGIN&lt;span style="color: black;"&gt; [Sam]&lt;/span&gt; WITH PASSWORD=&lt;span style="color: red;"&gt;N'MyPassw0rd!_'&lt;/span&gt;&lt;span style="color: #666666;"&gt;,&lt;/span&gt; DEFAULT_DATABASE=&lt;span style="color: black;"&gt;[AdventureWorks]&lt;span style="color: #666666;"&gt;,&lt;/span&gt;&lt;/span&gt; CHECK_EXPIRATION=OFF&lt;span style="color: #666666;"&gt;,&lt;/span&gt; CHECK_POLICY=OFF&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;CREATE LOGIN&lt;span style="color: black;"&gt; [Joe]&lt;/span&gt; WITH PASSWORD=&lt;span style="color: red;"&gt;N'MyPassw0rd!_'&lt;/span&gt;, DEFAULT_DATABASE=&lt;span style="color: black;"&gt;[AdventureWorks]&lt;span style="color: #666666;"&gt;,&lt;/span&gt;&lt;/span&gt; CHECK_EXPIRATION=OFF&lt;span style="color: #666666;"&gt;,&lt;/span&gt; CHECK_POLICY=OFF&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;Additionally I am adding these users to AdventureWorks. Two database roles also created for this purpose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;USE&lt;/span&gt; [AdventureWorks]&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;CREATE USER&lt;span style="color: black;"&gt; [Joe]&lt;/span&gt; FOR LOGIN&lt;span style="color: black;"&gt; [Joe]&lt;/span&gt; WITH DEFAULT_SCHEMA&lt;/span&gt;=[dbo]&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;CREATE USER&lt;/span&gt; [Sam] &lt;span style="color: blue;"&gt;FOR LOGIN&lt;/span&gt; [Sam] &lt;span style="color: blue;"&gt;WITH DEFAULT_SCHEMA&lt;/span&gt;=[dbo]&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;CREATE ROLE&lt;/span&gt; [Sales] &lt;span style="color: blue;"&gt;AUTHORIZATION &lt;/span&gt;[dbo]&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;EXEC &lt;/span&gt;&lt;span style="color: #660000;"&gt;sp_addrolemember&lt;/span&gt; &lt;span style="color: red;"&gt;N'Sales'&lt;/span&gt;,&lt;span style="color: red;"&gt; N'Joe'&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;EXEC&lt;span style="color: #660000;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #660000;"&gt;sp_addrolemember&lt;/span&gt; &lt;span style="color: red;"&gt;N'Sales'&lt;/span&gt;, &lt;span style="color: red;"&gt;N'Sam'&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;CREATE ROLE&lt;/span&gt; [Marketing] &lt;span style="color: blue;"&gt;AUTHORIZATION &lt;/span&gt;[dbo]&lt;/div&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;EXEC&lt;span style="color: #660000;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #660000;"&gt;sp_addrolemember&lt;/span&gt;  &lt;span style="color: red;"&gt;N'Marketing'&lt;/span&gt;, &lt;span style="color: red;"&gt;N'Sam'&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;To understand revoke, we need to understand that GRANT and DENY are two permissions, which a user or role can have.  There are few rules related to these permissions&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;GRANT and DENY are mutually exclusive permissions. That means, a user or role cannot have both GRANT and DENY permissions working. If both statements are issued against a user/role directly, the latest statement will stand as valid. (However, they could be given indirectly; the next rule explains it further.)  &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;GRANT EXECUTE ON &lt;/span&gt;[dbo].[uspLogError] &lt;span style="color: blue;"&gt;TO&lt;/span&gt; [Joe]&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;DENY EXECUTE ON&lt;/span&gt; [dbo].[uspLogError] &lt;span style="color: blue;"&gt;TO &lt;/span&gt;[Joe]&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;DENY has higher priority over GRANT.  That means, when a person gets both GRANT and DENY permissions, DENY will be in effect. (There are exceptions and mechanisms to overcome them. But it does not happen at the same level)  For example, use Joe could be a member of sales role. Joe may have GRANT permission to perform select operation over a table where, the sales role may have deny permission over the same table.  In this case Joe will not have read permission as DENY has higher priority. Similarly, if Joe has a DENY permission, even if his group has GRANT permission, DENY permission will work against him. &lt;/li&gt;
&lt;/ul&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;GRANT EXECUTE ON&lt;/span&gt; [dbo].[uspLogError] &lt;span style="color: blue;"&gt;TO &lt;/span&gt;[Sales]&lt;/div&gt;&lt;br /&gt;
The above statement, grants execute permission to sales role. As Joe and Sam are members of Sales role, they should get access to execute the procedure.  But Joe has explicit DENY permission and it takes priority over GRANT permission.  That makes only Sam having permission to execute the procedure.  &lt;br /&gt;
REVOKE is not a permission. Rather it is a command which removes the permission the user/role already has. Assume that you execute the next statement.&lt;br /&gt;
&lt;div style="color: blue;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;REVOKE EXECUTE ON &lt;/span&gt;[dbo].[uspLogError] &lt;span style="color: blue;"&gt;TO &lt;/span&gt;[Joe]&lt;/div&gt;&lt;br /&gt;
As the last statement was REVOKE, it will remove the permission given at the previous statement.  As Joe was given DENY rights before it will be removed.  It does not mean that he has GRANT permission now. The state is no permission is set for Joe on Execution of uspLogError.&lt;br /&gt;
Now Joe is also a member of Sales role.  So he can execute the procedure in his capacity of member of sales role. &lt;br /&gt;
Now consider this example:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;GRANT EXECUTE ON&lt;/span&gt; [dbo].[uspLogError] &lt;span style="color: blue;"&gt;TO &lt;/span&gt;[Marketing]&lt;/div&gt;&lt;br /&gt;
The first statement, grants execute permission to Marketing role.  &lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;REVOKE EXECUTE ON &lt;/span&gt;[dbo].[uspLogError] &lt;span style="color: blue;"&gt;TO &lt;/span&gt;[Sales]&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;Now the GRANT Permission is removed from sales role.  That means, all its members will have permission if they have direct or indirect permission only. This will make Joe losing the execute permission.  But Sam will still have permission as he is part of marketing role.&lt;br /&gt;
&lt;br /&gt;
I hope this explains REVOKE statement.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12327506-6244293668263263829?l=preethiviraj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/NlC_VNwtJ_qaSdqPtlzg6siMOkc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NlC_VNwtJ_qaSdqPtlzg6siMOkc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/NlC_VNwtJ_qaSdqPtlzg6siMOkc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NlC_VNwtJ_qaSdqPtlzg6siMOkc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/EncounterWithSqlServer/~4/a6NK7JN96uw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://preethiviraj.blogspot.com/feeds/6244293668263263829/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://preethiviraj.blogspot.com/2010/06/understanding-revoke.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/6244293668263263829?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/12327506/posts/default/6244293668263263829?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EncounterWithSqlServer/~3/a6NK7JN96uw/understanding-revoke.html" title="Understanding REVOKE" /><author><name>Preethiviraj Kulasingham</name><uri>http://www.blogger.com/profile/15899411508678919419</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://4.bp.blogspot.com/-u5pGdnx8gF0/Tle1JZ21jKI/AAAAAAAAAbc/esmRiWzkiz8/s220/Preethi.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://preethiviraj.blogspot.com/2010/06/understanding-revoke.html</feedburner:origLink></entry></feed>

