<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Andrew Kelly</title><subtitle type="html" /><id>http://sqlblog.com/blogs/andrew_kelly/atom.aspx</id><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/default.aspx" /><link rel="self" type="application/atom+xml" href="http://sqlblog.com/blogs/andrew_kelly/atom.aspx" /><generator uri="http://communityserver.org" version="2.1.61129.1">Community Server</generator><updated>2006-11-24T14:29:00Z</updated><entry><title>New England SQL Users Group &amp; Craig Freedman</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx</id><published>2008-05-06T19:50:23Z</published><updated>2008-05-06T19:50:23Z</updated><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Adam Machanic has already blogged about Craig's visit to New England coming up on May 8th but I wanted to re-iterate some points for the benefit of the folks planning to attend. Due to the large crowd expected we really need you to RSVP if you plan to attend to ensure we have enough chairs and Pizza for everyone:).&amp;#160; &lt;a href="http://www.red-gate.com/" target="_blank"&gt;Red Gate Software&lt;/a&gt; is sponsoring the event and it would be great to get the head count as close as possible to maximize the event potential. They made it possible to get a great speaker like Craig as out guest. See the link below if you need more info on how to RSVP or just want more details.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://sqlblog.com/blogs/adam_machanic/archive/2008/05/02/new-england-nesql-special-meeting-featuring-craig-freedman.aspx" href="http://sqlblog.com/blogs/adam_machanic/archive/2008/05/02/new-england-nesql-special-meeting-featuring-craig-freedman.aspx"&gt;http://sqlblog.com/blogs/adam_machanic/archive/2008/05/02/new-england-nesql-special-meeting-featuring-craig-freedman.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Thanks and hope to see you there...&lt;/p&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=New England SQL Users Group &amp;amp; Craig Freedman&amp;amp;body=Seen on SQLblog.com: %0A%0A%09New England SQL Users Group &amp;amp; Craig Freedman%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx" target="_blank" title = "Email New England SQL Users Group &amp;amp; Craig Freedman"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx&amp;amp;title=New+England+SQL+Users+Group+%26amp%3b+Craig+Freedman" target="_blank" title = "Submit New England SQL Users Group &amp;amp; Craig Freedman to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx&amp;amp;phase=2" target="_blank" title = "Submit New England SQL Users Group &amp;amp; Craig Freedman to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx&amp;amp;title=New+England+SQL+Users+Group+%26amp%3b+Craig+Freedman" target="_blank" title = "Submit New England SQL Users Group &amp;amp; Craig Freedman to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx&amp;amp;title=New+England+SQL+Users+Group+%26amp%3b+Craig+Freedman" target="_blank" title = "Submit New England SQL Users Group &amp;amp; Craig Freedman to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/05/06/new-england-sql-users-group-craig-freedman.aspx&amp;amp;title=New+England+SQL+Users+Group+%26amp%3b+Craig+Freedman&amp;amp;;top=1" target="_blank" title = "Add New England SQL Users Group &amp;amp; Craig Freedman to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=6657" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="User Groups" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/User+Groups/default.aspx" /></entry><entry><title>OT - Where is the gas cap?</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx</id><published>2008-04-04T13:33:50Z</published><updated>2008-04-04T13:33:50Z</updated><content type="html">&lt;p&gt;I know this is a SQL blog but I need to take my mind out of the technical mode for a few minutes to gain some sanity and hey, this is a blog after all:).&amp;#160; I was thinking about something my wife reminded me of while we were driving a rental car in Myrtle Beach last week. Being a consultant I rent a lot of cars or all makes &amp;amp; models as I am sure a lot of you do. But how many times have you pulled into a gas station in a rental car and the gas tank filler nozzle was on the wrong side? I am sure more than we want to admit. Well as it turns out every modern car (at least in the US) these days has a little arrow next to the gas gauge on the dashboard that points to the right or left indicating which side the gas cap is on. Now I bet most of you have been driving your own car for years and never even noticed this arrow. Why should you, you know which side it is on. Anyway I just wanted to share this little tidbit of almost useless information (until you actually need it that is). Happy car renting:).&lt;/p&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=OT - Where is the gas cap?&amp;amp;body=Seen on SQLblog.com: %0A%0A%09OT - Where is the gas cap?%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx" target="_blank" title = "Email OT - Where is the gas cap?"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx&amp;amp;title=OT+-+Where+is+the+gas+cap%3f" target="_blank" title = "Submit OT - Where is the gas cap? to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx&amp;amp;phase=2" target="_blank" title = "Submit OT - Where is the gas cap? to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx&amp;amp;title=OT+-+Where+is+the+gas+cap%3f" target="_blank" title = "Submit OT - Where is the gas cap? to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx&amp;amp;title=OT+-+Where+is+the+gas+cap%3f" target="_blank" title = "Submit OT - Where is the gas cap? to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/04/04/ot-where-is-the-gas-cap.aspx&amp;amp;title=OT+-+Where+is+the+gas+cap%3f&amp;amp;;top=1" target="_blank" title = "Add OT - Where is the gas cap? to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=6044" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="Trivia" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Trivia/default.aspx" /></entry><entry><title>When a Function is indeed a Constant</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx</id><published>2008-03-01T16:19:19Z</published><updated>2008-03-01T16:19:19Z</updated><content type="html">&lt;p&gt; In my last blog post:&lt;/p&gt;  &lt;p&gt;&lt;font size="1"&gt;&amp;#160;&lt;/font&gt;&lt;a title="http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx" href="http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx"&gt;&lt;font size="1"&gt;http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx&lt;/font&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;I mentioned that I ran across a situation in which GETDATE() used in a SELECT statement occasionally returned more than 1 value for the result set. That sparked quite a debate amongst SQL Server programmers who belonged to one of two camps in how they believed this really should behave.&amp;#160; For instance if you run the following SQL statement:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SELECT GETDATE() AS [The Datetime] FROM sys.sysobjects&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;Should you expect all the rows to have the same DateTime value or would you expect a different value for each row? Now in this simple example it would be easy to say that the query was so fast that there was not enough elapsed time between rows to give a different DateTime value and you could very well be correct. But this next example calls a UDF that introduces some lag as a result of the WHILE loop and returns GETDATE(). If you run that example you will definately see differences in the return from the function. But what about the plain GETDATE()?&amp;#160; Will it be the same value for all rows or similar to the UDF output? After all they are both spitting out GETDATE() right?&amp;#160; Well try it and see.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;USE tempdb      &lt;br /&gt;go       &lt;br /&gt;CREATE FUNCTION dbo.test$wait() &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;RETURNS DATETIME      &lt;br /&gt;AS       &lt;br /&gt;&amp;#160;&amp;#160; BEGIN       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DECLARE @I INT SET @I = 1       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHILE @I &amp;lt; 10000       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BEGIN       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SET @I = @I + 1       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; END       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RETURN (GETDATE())       &lt;br /&gt;&amp;#160;&amp;#160; END       &lt;br /&gt;GO       &lt;br /&gt;SELECT GETDATE() AS [Getdate],dbo.test$wait() AS [UDF]       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; FROM master.sys.sysobjects&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;As I am sure most of you will see it turns out that GETDATE() or any other &lt;em&gt;&lt;font color="#ff0000"&gt;non-deterministic runtime constant scalar function&lt;/font&gt;&lt;/em&gt; will indeed act as a &lt;font color="#ff0000"&gt;constant &lt;/font&gt;for the life of the query execution. What does that mean exactly?&amp;#160; Well in a nutshell it means these functions will be evaluated once at the beginning of the query execution and that value will be used for all resulting rows.&amp;#160; You will always get the same value and if you don't you have a bug. This behavior was confirmed today by one of the SQL Server developers who maintains this code and guarantees this behavior. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="com"&gt;While this may not be news to many of you (I was always under the impression this was the intended behavior) but it is to many others. There has been a lot of code written over the years that expects functions like this to return a potentially different value for each row in a single Select statement. That assumption is wrong and I wanted to get the word out there in order to minimize any future coding errors in this regard. As you can see in my original blog post that there is at least 1 older revision of SQL Server in which this was not the case, but don't let that fool you into thinking that is the intended behavior. Keep this behavior in mind as you code along in the future.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Comic Sans MS"&gt;&lt;/font&gt;&lt;/p&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=When a Function is indeed a Constant&amp;amp;body=Seen on SQLblog.com: %0A%0A%09When a Function is indeed a Constant%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx" target="_blank" title = "Email When a Function is indeed a Constant"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx&amp;amp;title=When+a+Function+is+indeed+a+Constant" target="_blank" title = "Submit When a Function is indeed a Constant to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx&amp;amp;phase=2" target="_blank" title = "Submit When a Function is indeed a Constant to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx&amp;amp;title=When+a+Function+is+indeed+a+Constant" target="_blank" title = "Submit When a Function is indeed a Constant to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx&amp;amp;title=When+a+Function+is+indeed+a+Constant" target="_blank" title = "Submit When a Function is indeed a Constant to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx&amp;amp;title=When+a+Function+is+indeed+a+Constant&amp;amp;;top=1" target="_blank" title = "Add When a Function is indeed a Constant to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=5382" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="Documentation" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx" /><category term="Tips &amp; Tricks" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Tips+_2600_+Tricks/default.aspx" /><category term="TSQL" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/TSQL/default.aspx" /></entry><entry><title>When GETDATE() is not a constant</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx</id><published>2008-02-27T15:53:00Z</published><updated>2008-02-27T15:53:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face="Comic Sans MS"&gt;A short while ago I was collecting wait stat information at a client and ran across a very peculiar situation that I would like to share. Let me start by saying that for years I have coded with the understanding that when you include a system function in the SELECT list of a TSQL statement the function was evaluated once at the beginning and that same value was used for each row returned. I am talking about a statement such as this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Comic Sans MS"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT GETDATE(), CompanyName FROM Customers&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Comic Sans MS"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Comic Sans MS"&gt;The output expected looks like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Alfreds Futterkiste &lt;BR&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Ana Trujillo Emparedados y helados &lt;BR&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Antonio Moreno Taquería &lt;BR&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Around the Horn &lt;BR&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Berglunds snabbköp &lt;BR&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Blauer See Delikatessen &lt;BR&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Blondesddsl père et fils &lt;BR&gt;2008-02-27 10:22:34.270&amp;nbsp;&amp;nbsp;&amp;nbsp; Bólido Comidas preparadas&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Comic Sans MS"&gt;Please note that I am not talking about a User Defined Function or once that takes a column as an input to determine the result. In this case I am specifically referring to &lt;FONT color=#ff8040&gt;GETDATE().&lt;/FONT&gt;&amp;nbsp; As you can see all the datetime values are exactly the same as expected. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Comic Sans MS"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; But what I experienced the other day was not as expected and quite concerning. What I got was for a single SELECT I received several different values for the GETDATE() column in the result set. This did not happen every time but happened enough times over a few days that I certainly took note of it. Now let me give a little more background because it was not just a SELECT. It was actually an INSERT INTO with the SELECT from a DMV. Not that any of this should matter anyway but for consistency sake let me give you the actual code (with a slight enhancement for demo purposes).&amp;nbsp; I added an extra column called R_ID that is used to store the unique value of each loop and I placed the Insert in a WHILE loop so it can be exercised.&amp;nbsp; In real life the Insert was only executed several times each day.&amp;nbsp; The code below can be used to see if your system is experiencing this behavior or not. Depending on the version and service pack you may have a different number of Waits but in my case with Microsoft SQL Server 2005 - 9.00.3159.00 (Intel X86) I get 201 rows for each pass. I suspect the version has everything to do with this behavior. The system at the time was running an older version of SQL Server 2005 which was:&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;9.00.2047.00.&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp; If anyone finds that their server returns different values of GETDATE() for any iteration of the select I would really be interested in what version of SQL Server you are running.&amp;nbsp; There is a LOT of code out there that relies on the value acting like a constant and having the same value in each row of a single SELECT statement. I suspect this is a bug in that particular version but who knows...&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Comic Sans MS"&gt;Please note that the sole purpose of the WHILE loop is just to give you a better chance of seeing the issue if it appears. We are looking for a difference in the datetime values for each instance of the SELECT only and not from loop to loop.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;SET NOCOUNT ON &lt;/P&gt;
&lt;P&gt;IF OBJECT_ID(N'[dbo].[wait_stats]',N'U') IS NULL &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE TABLE [dbo].[wait_stats] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ([R_ID] INT not null, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [wait_type] nvarchar(60) not null, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [waiting_tasks_count] bigint not null, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [wait_time_ms] bigint not null, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [max_wait_time_ms] bigint not null, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [signal_wait_time_ms] bigint not null, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [capture_time] datetime not null default getdate()) &lt;/P&gt;
&lt;P&gt;DECLARE @x INT &lt;BR&gt;SET @x = 1 &lt;/P&gt;
&lt;P&gt;WHILE @x &amp;lt; 100 &lt;BR&gt;BEGIN &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; INSERT INTO [dbo].[wait_stats] ([R_ID], [wait_type], [waiting_tasks_count], [wait_time_ms], [max_wait_time_ms], [signal_wait_time_ms], [capture_time])&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT @x, [wait_type], [waiting_tasks_count], [wait_time_ms], [max_wait_time_ms], [signal_wait_time_ms], GETDATE() &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM sys.dm_os_wait_stats &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @x = @x + 1 &lt;BR&gt;END &lt;/P&gt;
&lt;P&gt;--&amp;nbsp; Find the ones that have odd counts. If this returns any rows you had a difference in time for a single itteration.&lt;/P&gt;
&lt;P&gt;SELECT [R_ID], COUNT(*) AS [Totals], [capture_time] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM [dbo].[wait_stats] &lt;BR&gt;GROUP BY [R_ID], [capture_time] HAVING COUNT(*) &amp;lt;&amp;gt; 201&lt;/P&gt;
&lt;P&gt;&amp;nbsp;**Updates**&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;have some new and very important information about this subject and chose to put it in a new blog post that can be found here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx"&gt;http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=When GETDATE() is not a constant&amp;amp;body=Seen on SQLblog.com: %0A%0A%09When GETDATE() is not a constant%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx" target="_blank" title = "Email When GETDATE() is not a constant"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx&amp;amp;title=When+GETDATE()+is+not+a+constant" target="_blank" title = "Submit When GETDATE() is not a constant to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx&amp;amp;phase=2" target="_blank" title = "Submit When GETDATE() is not a constant to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx&amp;amp;title=When+GETDATE()+is+not+a+constant" target="_blank" title = "Submit When GETDATE() is not a constant to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx&amp;amp;title=When+GETDATE()+is+not+a+constant" target="_blank" title = "Submit When GETDATE() is not a constant to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/02/27/when-getdate-is-not-a-constant.aspx&amp;amp;title=When+GETDATE()+is+not+a+constant&amp;amp;;top=1" target="_blank" title = "Add When GETDATE() is not a constant to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=5302" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="TSQL" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/TSQL/default.aspx" /><category term="Bugs" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Bugs/default.aspx" /></entry><entry><title>Getting back to the basics with I/O</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx</id><published>2008-01-13T15:25:13Z</published><updated>2008-01-13T15:25:13Z</updated><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; One of the most common trends that I see related to performance &amp;amp; scalability with SQL Server is a poorly configured or implemented storage subsystem. There is a ton of information out there on this subject but in my opinion that is part of the problem.&amp;#160; Too much data is not always a good thing and there is a lot of misinformation out there as well. I also see a lot of systems that were configured based on the advice someone gave them or they read about which may have been great for that other system but not necessarily for theirs. &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; So I think it is time we got back to the Basics and Best Practices when it comes to I/O in SQL Server. Again in my opinion and my experience from seeing systems all over the world this list should get people off on the right foot if they are not sure what they need or how they should approach a proper I/O configuration. The first article hits the nail right on the head and is a great place to start. The next two give a very good understanding of what actually goes on when SQL Server makes I/O requests and explains the terminology so that everyone can talk the same language. The 4th link is a relatively new white paper to most that should be sort of a bible and gone over long before you deploy or even buy the equipment for your next SQL Server.&amp;#160; And finally there is a link that everyone should be aware of that gives you access to a whole host of white papers that should be read as needed.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;em&gt;&lt;strong&gt;SQL Server Storage TOP 10 Best Practices&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/storage-top-10.mspx" href="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/storage-top-10.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/storage-top-10.mspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;SQL Server 2000 I/O Basics&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlIObasics.mspx" href="http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlIObasics.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlIObasics.mspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;I/O part 2 for updates to SQl2000 SP4 and SQL2005&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.microsoft.com/technet/prodtechnol/sql/2005/iobasics.mspx" href="http://www.microsoft.com/technet/prodtechnol/sql/2005/iobasics.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/sql/2005/iobasics.mspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;SQL Server I/O Pre-Deployment Best Practices&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/pdpliobp.mspx" href="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/pdpliobp.mspx"&gt;http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/pdpliobp.mspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;Overall SQL Server Best Practices&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://technet.microsoft.com/en-us/sqlserver/bb331794.aspx" href="http://technet.microsoft.com/en-us/sqlserver/bb331794.aspx"&gt;http://technet.microsoft.com/en-us/sqlserver/bb331794.aspx&lt;/a&gt;&lt;/p&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=Getting back to the basics with I/O&amp;amp;body=Seen on SQLblog.com: %0A%0A%09Getting back to the basics with I/O%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx" target="_blank" title = "Email Getting back to the basics with I/O"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx&amp;amp;title=Getting+back+to+the+basics+with+I%2fO" target="_blank" title = "Submit Getting back to the basics with I/O to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx&amp;amp;phase=2" target="_blank" title = "Submit Getting back to the basics with I/O to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx&amp;amp;title=Getting+back+to+the+basics+with+I%2fO" target="_blank" title = "Submit Getting back to the basics with I/O to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx&amp;amp;title=Getting+back+to+the+basics+with+I%2fO" target="_blank" title = "Submit Getting back to the basics with I/O to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2008/01/13/getting-back-to-the-basics-with-i-o.aspx&amp;amp;title=Getting+back+to+the+basics+with+I%2fO&amp;amp;;top=1" target="_blank" title = "Add Getting back to the basics with I/O to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=4517" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="Documentation" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx" /><category term="Best Paractices" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Best+Paractices/default.aspx" /><category term="Performance" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Performance/default.aspx" /><category term="Storage" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Storage/default.aspx" /><category term="I/O" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/I_2F00_O/default.aspx" /></entry><entry><title>Exists Vs. Count(*) - The battle never ends...</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx</id><published>2007-12-16T01:27:26Z</published><updated>2007-12-16T01:27:26Z</updated><content type="html">&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; I am still amazed at how many of the database applications written today still disregard some basic rules of thumb when it comes to accessing the data. One in particular is the use of &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;to check to see if there are any rows that match some criteria. The technique of using &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;over &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;has been widely publicized and is in pretty much every best practices document I have come across. So why are database developers still using &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;instead of &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;all over the place?&amp;#160; If it is because people just don't believe or recognize the benefits of it? Or is the concept of &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;difficult for new programmers to grasp?&amp;#160; I am not really sure since I have heard both views. So to cover both bases I will show a little demo of why &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;is almost always a better way to code when you simply need to see if there is at least 1 row that matches some condition in the WHERE clause. Of course if you really need to know exactly how many match that condition then &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;is appropriate so hopefully this won't confuse anyone in that regard.&lt;/p&gt;  &lt;p&gt;Lets use the Adventureworks database and turn statistics IO on so we can see the number of reads associated with each query. We will then compare &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;with &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;so there is no mistake on how much work is being done in relation to each other.&lt;/p&gt;  &lt;p&gt;USE Adventureworks    &lt;br /&gt;GO&lt;/p&gt;  &lt;p&gt;SET STATISTICS IO ON &lt;/p&gt;  &lt;p&gt;GO&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;First lets look at a situation in which there is an index to satisfy the WHERE clause and there are only 2 matching rows:&lt;/p&gt;  &lt;p&gt;IF (SELECT &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;FROM sales.salesorderdetail     &lt;br /&gt;WHERE ProductID = 870 ) &amp;gt; 0&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; Print 'Yes'&lt;/p&gt;  &lt;p&gt;IF &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;(SELECT * FROM sales.salesorderdetail WHERE ProductID = 870)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Print 'Yes' &lt;/p&gt;  &lt;p&gt;Table 'SalesOrderDetail'. Scan count 1, logical reads &lt;font color="#ff0000"&gt;3&lt;/font&gt;, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.     &lt;br /&gt;Table 'SalesOrderDetail'. Scan count 1, logical reads &lt;font color="#008000"&gt;2&lt;/font&gt;, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As we can see from the Logical reads there was only a difference of 1 between the two queries since the amount of matching rows was so small. So in this case there was not a significant difference although it was still 1/3 more expensive to use &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;instead of &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt;&lt;/font&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now lets do the same but with 4688 matching rows:&lt;/p&gt;  &lt;p&gt;IF (SELECT &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;FROM sales.salesorderdetail     &lt;br /&gt;WHERE ProductID = 897 ) &amp;gt; 0 &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; Print 'Yes'&lt;/p&gt;  &lt;p&gt;IF &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;(SELECT * FROM sales.salesorderdetail WHERE ProductID = 897)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Print 'Yes' &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Table 'SalesOrderDetail'. Scan count 1, logical reads &lt;font color="#ff0000"&gt;11&lt;/font&gt;, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.     &lt;br /&gt;Table 'SalesOrderDetail'. Scan count 1, logical reads &lt;font color="#008000"&gt;2&lt;/font&gt;, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now the cost for the &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;is over 5 times the &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt;&lt;/font&gt;. This still may not seem like a lot to you. But if you were calling this queries thousands of times a second this would be a big deal. And remember this index is pretty small overall still.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;OK now lets try this on a column with no index in that same table. There are 357 rows that match but there are a total of 121,317 in the table. &lt;/p&gt;  &lt;p&gt;IF (SELECT &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;FROM sales.salesorderdetail     &lt;br /&gt;WHERE ModifiedDate = '20010701 00:00:00.000' ) &amp;gt; 0 &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; Print 'Yes'&lt;/p&gt;  &lt;p&gt;IF &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;(SELECT * FROM sales.salesorderdetail WHERE ModifiedDate = '20010701 00:00:00.000')     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Print 'Yes' &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Table 'SalesOrderDetail'. Scan count 1, logical reads &lt;font color="#ff0000"&gt;1241&lt;/font&gt;, physical reads 0, read-ahead reads 331, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.     &lt;br /&gt;Table 'SalesOrderDetail'. Scan count 1, logical reads &lt;font color="#008000"&gt;5&lt;/font&gt;, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This is now almost 250 times more expensive to do a &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;vs. an &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt;&lt;/font&gt;. Both queries scanned the table but the &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS &lt;/font&gt;&lt;/font&gt;was able to at least do a partial scan do to the fact it can stop after it finds the very first matching row. Where as the &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;must read each and every row in the entire table to determine if they match the criteria and how many there are. That is the key folks. The ability to stop working after the first row that meets the criteria of the WHERE clause is what makes &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;so efficient.&amp;#160; The optimizer knows of this behavior and can factor that in as well. Now keep in mind that these tables are relatively small compared to most databases in the real world. So the figures of the &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;queries would be multiplied many times on larger tables. You could easily get hundred's of thousands of reads or more on tables with millions of rows but the &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;will still only have just a few reads on any queries that can use an index to satisfy the WHERE clause. &lt;/p&gt;  &lt;p&gt;Hopefully this will help to persuade those last holdouts who insist on using &lt;font color="#ff8040"&gt;COUNT(*) &lt;/font&gt;everywhere even when &lt;font color="#00ff00"&gt;&lt;font color="#ff00ff"&gt;EXISTS&lt;/font&gt; &lt;/font&gt;is the clear choice.&amp;#160; One last note, make sure to turn off the statistics IO when done.&lt;/p&gt;  &lt;p&gt;SET STATISTICS IO OFF&lt;/p&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=Exists Vs. Count(*) - The battle never ends...&amp;amp;body=Seen on SQLblog.com: %0A%0A%09Exists Vs. Count(*) - The battle never ends...%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx" target="_blank" title = "Email Exists Vs. Count(*) - The battle never ends..."&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx&amp;amp;title=Exists+Vs.+Count(*)+-+The+battle+never+ends..." target="_blank" title = "Submit Exists Vs. Count(*) - The battle never ends... to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx&amp;amp;phase=2" target="_blank" title = "Submit Exists Vs. Count(*) - The battle never ends... to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx&amp;amp;title=Exists+Vs.+Count(*)+-+The+battle+never+ends..." target="_blank" title = "Submit Exists Vs. Count(*) - The battle never ends... to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx&amp;amp;title=Exists+Vs.+Count(*)+-+The+battle+never+ends..." target="_blank" title = "Submit Exists Vs. Count(*) - The battle never ends... to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx&amp;amp;title=Exists+Vs.+Count(*)+-+The+battle+never+ends...&amp;amp;;top=1" target="_blank" title = "Add Exists Vs. Count(*) - The battle never ends... to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=3999" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="Documentation" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx" /><category term="Delevoper" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Delevoper/default.aspx" /><category term="Tips &amp; Tricks" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Tips+_2600_+Tricks/default.aspx" /></entry><entry><title>Vista's Perfmon Reports</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx</id><published>2007-12-15T02:48:06Z</published><updated>2007-12-15T02:48:06Z</updated><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;A short while back I had to buy a new laptop and one of the choices I had to make was whether to run Vista or XP. While that is the subject for a whole different blog post the short answer is I decided to go with Vista Ultimate. I knew a lot of things changed between XP and Vista but it never dawned on me that Perfmon got such a makeover. I don&amp;#8217;t mean the real time counter monitoring aspect or what we call the Performance or System Monitor, I am talking about the Counter Logs mode. This is the area in which you can set up counters to be collected behind the scenes and in Vista is now called &amp;#8220;&lt;b&gt;&lt;i&gt;Data Collector Sets&lt;/i&gt;&lt;/b&gt;&amp;#8221;. Even though all of the previous functionality is still there plus a whole lot more the look and feel is totally different. Now my intent is not to talk about all of these changes per say, just one aspect in particular. But I highly recommend if you haven&amp;#8217;t played with Perfmon in Vista or Longhorn that you do so when you get a minute.&lt;/p&gt;  &lt;p&gt;The section I want to highlight here are the new reporting features found under the Reports section of Perfmon. After you have created a new Data Collection Set you will see a corresponding entry in the Reports section as well. If you look at the properties of this you will see a dialog similar to the one below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/andrew_kelly/WindowsLiveWriter/VistasPerfmonReports_13090/ReportProperties_2.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="280" alt="ReportProperties" src="http://sqlblog.com/blogs/andrew_kelly/WindowsLiveWriter/VistasPerfmonReports_13090/ReportProperties_thumb.png" width="252" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Again I am not going to go into all the aspects of the data manager but if you check the checkbox in the lower left hand corner you get the ability for Perfmon to automatically generate a series of XML and HTML reports each time the collection set is completed. I see a lot of people do a fair amount of manual labor to generate a report similar to what you now get for free. It will look similar to the report I show below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/andrew_kelly/WindowsLiveWriter/VistasPerfmonReports_13090/PerfmonReport_2.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="472" alt="PerfmonReport" src="http://sqlblog.com/blogs/andrew_kelly/WindowsLiveWriter/VistasPerfmonReports_13090/PerfmonReport_thumb.png" width="458" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Of course it will be specific to the counters you set up in the data collector set but you get the idea. Overall it will take some getting used to the new features and layouts in Perfmon but there is no getting around it. Sooner or later we will all end up on Vista or Longhorn anyway. The new look can be quite confusing at times but it brings a whole host of new features that just wouldn&amp;#8217;t be possible the old way. &lt;/p&gt;  &lt;p&gt;Good luck &lt;/p&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=Vista's Perfmon Reports&amp;amp;body=Seen on SQLblog.com: %0A%0A%09Vista's Perfmon Reports%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx" target="_blank" title = "Email Vista's Perfmon Reports"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx&amp;amp;title=Vista%27s+Perfmon+Reports" target="_blank" title = "Submit Vista's Perfmon Reports to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx&amp;amp;phase=2" target="_blank" title = "Submit Vista's Perfmon Reports to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx&amp;amp;title=Vista%27s+Perfmon+Reports" target="_blank" title = "Submit Vista's Perfmon Reports to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx&amp;amp;title=Vista%27s+Perfmon+Reports" target="_blank" title = "Submit Vista's Perfmon Reports to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/14/vista-s-perfmon-reports.aspx&amp;amp;title=Vista%27s+Perfmon+Reports&amp;amp;;top=1" target="_blank" title = "Add Vista's Perfmon Reports to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=3980" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author></entry><entry><title>Successful Backup Messages No More...</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx</id><published>2007-10-29T17:09:00Z</published><updated>2007-10-29T17:09:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;How many times have you asked for a way to turn off the behavior in SQL Server that logs successful backup messages to the SQL Server Logs and to the Windows Application Event Logs? If you are like most DBA’s probably a lot. I have been asking for this feature for ages. I have sent email to SQLWish, filed on LadyBug and most recently on Connect with never any positive feedback. Well the other day I happened to be on campus in Redmond and was talking to Kevin Farlee (Thanks Kevin) who is a PM on the Storage Engine team for SQL Server.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I asked again if we could have this feature and he said he would get back to me. Well he did and the answer is the ability was already there in the form of a trace flag.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I could not believe this functionality was there all along and no one knew about it. Well at least I didn’t and I am pretty sure most others as well. So how do you use this functionality?&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Pretty easy actually and here is an example. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;First we will backup the Northwind database (you can substitute your own) to disk. We will then use another feature of SQL Server that I think is also under utilized, sp_readerrorlog to place the contents into a temp table so we can query against it. We then can see the backup message that was logged.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;BACKUP&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;DATABASE&lt;/SPAN&gt; [Northwind] &lt;SPAN style="COLOR:blue;"&gt;TO&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;DISK&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; N&lt;SPAN style="COLOR:red;"&gt;'C:\Northwind_BU.bak'&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;WITH&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;INIT&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;STATS&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;IF&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;OBJECT_ID&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'[tempdb].[dbo].[#ErrorLogs]'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;N&lt;SPAN style="COLOR:red;"&gt;'U'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;IS&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;DROP&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;TABLE&lt;/SPAN&gt; [dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[#ErrorLogs]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;CREATE&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;TABLE&lt;/SPAN&gt; [dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[#ErrorLogs] &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;[LogDate] &lt;SPAN style="COLOR:blue;"&gt;DATETIME&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL,&lt;/SPAN&gt; [ProcessInfo] &lt;SPAN style="COLOR:blue;"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;20&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL,&lt;/SPAN&gt; [Text] &lt;SPAN style="COLOR:blue;"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:fuchsia;"&gt;MAX&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;INSERT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;INTO&lt;/SPAN&gt; #ErrorLogs &lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;[LogDate]&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; [ProcessInfo]&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; [Text]&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;EXEC&lt;/SPAN&gt; [master]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[sp_readerrorlog] 0 &lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:gray;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;FROM&lt;/SPAN&gt; [dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[#ErrorLogs] &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;WHERE&lt;/SPAN&gt; [Text] &lt;SPAN style="COLOR:gray;"&gt;LIKE&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'Database Back%Northwind%'&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;FONT face=Calibri size=3&gt;Next we will turn on Trace Flag # 3226 and try it again. This flag can be set via TSQL or via a startup parameter. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;DBCC&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; TRACEON &lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;3226&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;BACKUP&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;DATABASE&lt;/SPAN&gt; [Northwind] &lt;SPAN style="COLOR:blue;"&gt;TO&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;DISK&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; N&lt;SPAN style="COLOR:red;"&gt;'C:\Northwind_BU.bak'&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;WITH&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;INIT&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;STATS&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;TRUNCATE&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;TABLE&lt;/SPAN&gt; [dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[#ErrorLogs] &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;INSERT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;INTO&lt;/SPAN&gt; #ErrorLogs &lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;[LogDate]&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; [ProcessInfo]&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; [Text]&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;EXEC&lt;/SPAN&gt; [master]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[sp_readerrorlog] 0 &lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:gray;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;FROM&lt;/SPAN&gt; [dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[#ErrorLogs] &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;WHERE&lt;/SPAN&gt; [Text] &lt;SPAN style="COLOR:gray;"&gt;LIKE&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'Database Back%Northwind%'&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;FONT face=Calibri size=3&gt;Notice that now the most recent backup is not in the log nor will it be in the Event log. No longer will we have to weed thru all those successful messages just to see if there was a failure.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Yes all failures will still be reported as before.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;And if you want to get back to the default behavior just turn the flag back off as such:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:gray;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:green;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;-- To turn the behavior off &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 0pt;LINE-HEIGHT:normal;mso-layout-grid-align:none;"&gt;&lt;SPAN style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt;DBCC&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE:10pt;FONT-FAMILY:'Courier New';mso-no-proof:yes;"&gt; TRACEOFF &lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;3226&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=Successful Backup Messages No More...&amp;amp;body=Seen on SQLblog.com: %0A%0A%09Successful Backup Messages No More...%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx" target="_blank" title = "Email Successful Backup Messages No More..."&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx&amp;amp;title=Successful+Backup+Messages+No+More..." target="_blank" title = "Submit Successful Backup Messages No More... to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx&amp;amp;phase=2" target="_blank" title = "Submit Successful Backup Messages No More... to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx&amp;amp;title=Successful+Backup+Messages+No+More..." target="_blank" title = "Submit Successful Backup Messages No More... to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx&amp;amp;title=Successful+Backup+Messages+No+More..." target="_blank" title = "Submit Successful Backup Messages No More... to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/10/29/successful-backup-messages-no-more.aspx&amp;amp;title=Successful+Backup+Messages+No+More...&amp;amp;;top=1" target="_blank" title = "Add Successful Backup Messages No More... to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=3140" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="Trace Flag" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Trace+Flag/default.aspx" /><category term="Maintenance" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Maintenance/default.aspx" /><category term="Backup" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Backup/default.aspx" /></entry><entry><title>Double Standard?</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx</id><published>2007-09-27T20:22:00Z</published><updated>2007-09-27T20:22:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;While this is nothing new, a conversation I had with a client the other day got me thinking more than I wanted to about what I see as sort of a double – standard for lack of a better term at the moment.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Now I fully realize this can turn into a full out war of opinions, I feel the need to blog about it. But please keep in mind the focus of the argument and understand that I am in no way bashing or hyping one side vs. the other. &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;What I am referring to is the mindset that it is OK or even encouraged for an application developer to develop both the app objects and the database objects. But it is not OK for a DBA to also develop application code.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The point the client had was that the developer of an application needs to be somewhat of an expert in C#, VB etc. but they don’t need to know that much about databases to do a adequate job because SQL Server is simple.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;So the general idea seems to be that a DBA doesn’t require as much skill to architect a database as a C# developer needs to develop an application.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;So most people would never think of letting a DBA develop both the application and the database but it’s perfectly fine the other way around. Now I have been both a developer and a DBA so I have seen both sides of the fence and if you are talking about an application that doesn’t require a large or complicated database schema I don’t see too much problem with that. But how many small apps stay that way?&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Or what about ones that were always intended to be large and complicated?&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Why do so many people think that there is less of a need for a truly qualified person to design the database side? I see way too many apps that suffer from poor database design and implementation, especially the larger they get.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;If you wait until the database is hundreds of GB’s or even TB’s in size before you make the proper design changes to accommodate that it is often too late to do the right things. I don’t think that is too hard of a concept to understand or even agree with.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Sure there are people who can be experts as both an application developer and a database architect as in any two skilled trades. But let’s face it that is the minority not the majority. &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;I simply don’t expect most DBA’s to be experts in both SQL Server and C#. But I also don’t expect most developers to be experts in C# and SQL Server either.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;So why the double standard? Why do so many companies today feel it is perfectly OK to have the C# developer also do the database design and coding? What is it about proper database design and architecting that appears to be so simple that they feel developers can do just as good a job on the database with dramatically less training and experience than they typically have for the application side?&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=Double Standard?&amp;amp;body=Seen on SQLblog.com: %0A%0A%09Double Standard?%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx" target="_blank" title = "Email Double Standard?"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx&amp;amp;title=Double+Standard%3f" target="_blank" title = "Submit Double Standard? to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx&amp;amp;phase=2" target="_blank" title = "Submit Double Standard? to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx&amp;amp;title=Double+Standard%3f" target="_blank" title = "Submit Double Standard? to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx&amp;amp;title=Double+Standard%3f" target="_blank" title = "Submit Double Standard? to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/27/double-standard.aspx&amp;amp;title=Double+Standard%3f&amp;amp;;top=1" target="_blank" title = "Add Double Standard? to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=2718" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="Delevoper" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Delevoper/default.aspx" /><category term="DBA" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/DBA/default.aspx" /></entry><entry><title>DBCC OPENTRAN() behavior</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx</id><published>2007-09-25T20:25:00Z</published><updated>2007-09-25T20:25:00Z</updated><content type="html">&lt;P&gt;I recently was bitten by some not so obvious behavior with DBCC OPENTRAN() that I would like to share.&amp;nbsp; Basically this command is supposed to show you the oldest open transaction within the specified database or the current one if none is specified. If you run the example below you can see the expected behavior.&lt;/P&gt;
&lt;P&gt;USE Tempdb ;&lt;BR&gt;GO&lt;BR&gt;CREATE TABLE [dbo].[T1]([Col1] int NOT NULL, [Col2] char(3) ) ;&lt;BR&gt;GO&lt;BR&gt;INSERT INTO [dbo].[T1] ([Col1], [Col2]) VALUES (101, 'abc');&lt;BR&gt;GO&lt;BR&gt;BEGIN TRAN ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UPDATE [dbo].[T1] SET [Col2] = 'abc' WHERE [Col1] = 101 ;&lt;BR&gt;GO&lt;/P&gt;
&lt;P&gt;DBCC OPENTRAN();&lt;/P&gt;
&lt;P&gt;ROLLBACK TRAN;&lt;BR&gt;GO&lt;BR&gt;DROP TABLE [dbo].[T1];&lt;BR&gt;GO&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This should show you something similar to this:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Oldest active transaction:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPID (server process ID): 52&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UID (user ID) : -1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : user_transaction&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;LSN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : (22:248:502)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start time&amp;nbsp;&amp;nbsp;&amp;nbsp; : Sep 25 2007&amp;nbsp; 5:28:59:700PM&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 0x010500000000000515000000864be9f541b8a3fc1f944d76e8030000&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBCC execution completed. If DBCC printed error messages, contact your system administrator.&lt;BR&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;But now add a PK constraint into the mix and run it again.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;USE Tempdb ;&lt;BR&gt;GO&lt;BR&gt;CREATE TABLE [dbo].[T1]([Col1] int NOT NULL, [Col2] char(3) ) ;&lt;BR&gt;GO&lt;BR&gt;ALTER TABLE [dbo].[T1] ADD CONSTRAINT [PK_T1] PRIMARY KEY CLUSTERED ([Col1] ASC) ;&lt;/P&gt;
&lt;P&gt;GO&lt;BR&gt;INSERT INTO [dbo].[T1] ([Col1], [Col2]) VALUES (101, 'abc');&lt;BR&gt;GO&lt;BR&gt;BEGIN TRAN ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UPDATE [dbo].[T1] SET [Col2] = 'abc' WHERE [Col1] = 101 ;&lt;BR&gt;GO&lt;/P&gt;
&lt;P&gt;DBCC OPENTRAN();&lt;/P&gt;
&lt;P&gt;ROLLBACK TRAN;&lt;BR&gt;GO&lt;BR&gt;DROP TABLE [dbo].[T1];&lt;BR&gt;GO&lt;/P&gt;
&lt;P&gt;You now get this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; No active open transactions.&lt;BR&gt;&amp;nbsp;&amp;nbsp; DBCC execution completed. If DBCC printed error messages, contact your system administrator.&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Wait a minute, what's going on here. Are you telling me that just by adding a PK I changed the transaction? Well yes &amp;amp; no. If you look closely at the UPDATE statement it is updating the value with the same value that it already had. If you substitute the UPDATE with the one below you will get the expected output from DBCC OPENTRAN().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UPDATE [dbo].[T1] SET [Col2] = 'xyz' WHERE [Col1] = 101 ;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In reality the transaction is not logged even if we create a clustered index vs. the PK constraint. A Non-Clustered index has the same effect as no index. So what does this all mean?&amp;nbsp;&amp;nbsp;Based on some assumptions that I and some fellow MVP's had regarding this along with some further testing I came to two conclusions.&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;&amp;nbsp;As expected the&amp;nbsp;Clustered&amp;nbsp;Index&amp;nbsp;or PK&amp;nbsp;allows SQL Server to pinpoint the row and optimize the work done.&amp;nbsp;But it must also be deeper rooted than that when it comes to how it actually logs this information in the transaction log. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;&amp;nbsp;The&amp;nbsp;Engine is smart enough to realize that no changes have actually been made and does not log anything into the transaction log when the column in the WHERE clause has a Clustered index or PK constraint. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since DBCC OPENTRAN() looks into the Transaction Log for these open transactions we can assume that there are certain optimizations built into the engine that minimize logging under the right conditions. So if you ever wonder why OPENTRAN isn't returning what you expect you should look to see if this may be the reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=DBCC OPENTRAN() behavior&amp;amp;body=Seen on SQLblog.com: %0A%0A%09DBCC OPENTRAN() behavior%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx" target="_blank" title = "Email DBCC OPENTRAN() behavior"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx&amp;amp;title=DBCC+OPENTRAN()+behavior" target="_blank" title = "Submit DBCC OPENTRAN() behavior to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx&amp;amp;phase=2" target="_blank" title = "Submit DBCC OPENTRAN() behavior to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx&amp;amp;title=DBCC+OPENTRAN()+behavior" target="_blank" title = "Submit DBCC OPENTRAN() behavior to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx&amp;amp;title=DBCC+OPENTRAN()+behavior" target="_blank" title = "Submit DBCC OPENTRAN() behavior to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/25/dbcc-opentran-behavior.aspx&amp;amp;title=DBCC+OPENTRAN()+behavior&amp;amp;;top=1" target="_blank" title = "Add DBCC OPENTRAN() behavior to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=2681" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author><category term="DBCC" scheme="http://sqlblog.com/blogs/andrew_kelly/archive/tags/DBCC/default.aspx" /></entry><entry><title>LINQ to the rescue</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx</id><published>2007-09-06T15:22:00Z</published><updated>2007-09-06T15:22:00Z</updated><content type="html">I heard someone state that LINQ (see &lt;A href="http://www.sqlmag.com/Article/ArticleID/48759/sql_server_48759.html"&gt;http://www.sqlmag.com/Article/ArticleID/48759/sql_server_48759.html&lt;/A&gt;&amp;nbsp;for details on LINQ) was going to rescue developers from having to know TSQL. Well if that's true then who will rescue us from LINQ?&amp;nbsp; LINQ like so many other technologies that have come about makes certain things easier by abstracting the underlying objects or code and providing a "simpler" interface. That sounds great but as we have learned over and over again this comes at a price. The price here will ultimately be performance in the database. LINQ will allow you to write an English like statement that will be translated into TSQL and sent to the database as essentially an adhoc sql statement. So again instead of steering developers towards writing efficient and reusable stored procedures we give them the exact opposite. We will end up with code that has little chance of being optimized properly and few chances of getting plan reuse. As a consultant specializing in scalability and performance I can tell you that the number one culprit out there in this regard is exactly these types of applications. Ones in which the developers are coerced or even forced into using adhoc code due to time constraints or technologies such as LINQ. Now don't get me wrong I am not blaming these issues on developers, I used to be one:). They just happen to be the ones creating the code for the database these days. Most DBA's if they had their way would prefer to use stored procedures first. Only time will tell but I expect my job as a performance consultant to heat up in the future once everyone starts using LINQ. You see most large apps started out small and performance isn't as much of an issue then. But they tend to grow very large these days and adhoc sql and poorly optimized queries just don't cut it in the long run. I hope to be proven wrong but history leads me to believe otherwise. Any way happy coding...
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=LINQ to the rescue&amp;amp;body=Seen on SQLblog.com: %0A%0A%09LINQ to the rescue%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx" target="_blank" title = "Email LINQ to the rescue"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx&amp;amp;title=LINQ+to+the+rescue" target="_blank" title = "Submit LINQ to the rescue to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx&amp;amp;phase=2" target="_blank" title = "Submit LINQ to the rescue to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx&amp;amp;title=LINQ+to+the+rescue" target="_blank" title = "Submit LINQ to the rescue to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx&amp;amp;title=LINQ+to+the+rescue" target="_blank" title = "Submit LINQ to the rescue to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/09/06/linq-to-the-rescue.aspx&amp;amp;title=LINQ+to+the+rescue&amp;amp;;top=1" target="_blank" title = "Add LINQ to the rescue to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=2470" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author></entry><entry><title>Junctions in Windows</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx</id><published>2007-08-21T12:43:00Z</published><updated>2007-08-21T12:43:00Z</updated><content type="html">&lt;P&gt;I had known for a while that as of Windows 2000 there was a way to create what I called a Drive Shortcut but I never could find the documentation on how to actually do it. It turns out this was included in the resource kit which is probably why i never stumbled across it. But I still get asked on a regular basis if it is possible to map a specific folder location to a logical drive letter similar to the way you map a networked share. The idea being that it would look like any other drive except it would actually point to a much longer or obscure physical mapping. Well I just saw a post from Mark Russinovich that talks about his utility called Junction that allows you to do this very easily without the resource kit. Windows Vista has a neat little feature in the Windows Explorer that allows you to map folder locations as a favorite but from what I can see you still need something like this to make it visable from other places outside Windows Explorer as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx"&gt;http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=Junctions in Windows&amp;amp;body=Seen on SQLblog.com: %0A%0A%09Junctions in Windows%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx" target="_blank" title = "Email Junctions in Windows"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx&amp;amp;title=Junctions+in+Windows" target="_blank" title = "Submit Junctions in Windows to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx&amp;amp;phase=2" target="_blank" title = "Submit Junctions in Windows to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx&amp;amp;title=Junctions+in+Windows" target="_blank" title = "Submit Junctions in Windows to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx&amp;amp;title=Junctions+in+Windows" target="_blank" title = "Submit Junctions in Windows to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/08/21/junctions-in-windows.aspx&amp;amp;title=Junctions+in+Windows&amp;amp;;top=1" target="_blank" title = "Add Junctions in Windows to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=2270" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author></entry><entry><title>Customizing BooksOnLine Help Collection</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx</id><published>2007-07-13T17:18:00Z</published><updated>2007-07-13T17:18:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="FONT-SIZE:10pt;LINE-HEIGHT:115%;FONT-FAMILY:'Arial','sans-serif';"&gt;I got into a situation the other day where I looked up an entry in BOL (BooksOnLine) and it pulled up the command for SQL CE edition instead of SQL Server 2005. Now in this case the command was "Update Statistics" and it just so happens the CE version has an ON clause where as the regular SQL Server editions don't. Since the CE version was the one that popped up first I just assumed I was looking at the correct command. But after fiddling with it for quite some time with syntax errors I was very disappointed to find I had been looking at the CE version all along. What idiot developer decided to make a command in CE that did the same thing,&amp;nbsp;and was named the same&amp;nbsp;as the regular edition yet have slightly different syntax is beyond me. But I digress. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="FONT-SIZE:10pt;LINE-HEIGHT:115%;FONT-FAMILY:'Arial','sans-serif';"&gt;Any way this is certainly not the first time something like this has happened with help files for SQL Server or Visual Studio. But hopefully I can now make it the last. I was reminded from a fellow MVP that you can choose which technologies get searched in BOL from the Search Screen by clicking on the little button with the down arrow next to the word "Technology" on the search screen. If you uncheck CE for instance it will no longer be considered in the Searches. But that still didn't fix the Index portion of BOL. I then learned from a former MVP (now Microsoft employee) by the nickname of UC that you can do something similar with the index as well. It is actually called the "Help Collection". You can read up about more details’ of Help Collections in BOL at this location:&amp;nbsp; ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqlgtst9/html/ef798cc8-87cf-4d60-a7bf-9e061bdd0052.htm.&amp;nbsp;&amp;nbsp; But near the bottom in the "Removing Help Collections" section there is a link to a utility that can allow you to set what gets used when you use the regular part or Index of BOL. This is listed as the "SQL Server 2005 Combined Help Collection Manager" and brings you here:&amp;nbsp; ms-help://MS.SQLCC.v9/sqlcc9/html/b06d0f98-ef00-4b03-9f5d-b5c184b8df92.htm.&amp;nbsp; So if this has ever happened to you or you simply want to fine tune what areas get searched you know where to go.&lt;/SPAN&gt;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=Customizing BooksOnLine Help Collection&amp;amp;body=Seen on SQLblog.com: %0A%0A%09Customizing BooksOnLine Help Collection%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx" target="_blank" title = "Email Customizing BooksOnLine Help Collection"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx&amp;amp;title=Customizing+BooksOnLine+Help+Collection" target="_blank" title = "Submit Customizing BooksOnLine Help Collection to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx&amp;amp;phase=2" target="_blank" title = "Submit Customizing BooksOnLine Help Collection to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx&amp;amp;title=Customizing+BooksOnLine+Help+Collection" target="_blank" title = "Submit Customizing BooksOnLine Help Collection to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx&amp;amp;title=Customizing+BooksOnLine+Help+Collection" target="_blank" title = "Submit Customizing BooksOnLine Help Collection to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/07/13/customizing-booksonline-help-collection.aspx&amp;amp;title=Customizing+BooksOnLine+Help+Collection&amp;amp;;top=1" target="_blank" title = "Add Customizing BooksOnLine Help Collection to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=1711" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author></entry><entry><title>The Joy's of traveling</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx</id><published>2007-03-17T14:49:00Z</published><updated>2007-03-17T14:49:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT face=Calibri size=3&gt;As a long time consultant I have certainly had my share of travel woes. And although this latest experience is not the worst experience I have had I think it rated an entry in my blog. I (along with 1700 other MVP's) spent the last few days out in Redmond at the 2007 MVP summit. It was a great time and a fantastic opportunity to get a heads up on the upcoming version of SQL Server called Katmai. The last night a few of my fellow MVP's and I spent the night with a few unnamed members from the SQL product team visiting the different nightlife establishments in Seattle until about 3:00AM. But unfortunately that is where the fun ended. It started the next morning when I had to get up with a terrible hangover and head off to the airport. The 4 plus hour plane ride to Detroit was basically uneventful but also very uncomfortable due to the fact the head rest did not match my body height. This made the hangover even harder to deal with. Then once I arrived in Detroit I was informed that due to the storm on the east coast I could not make it back to Manchester NH until at least 6:30PM the next night. By this time all the local hotels were booked solid. I found a Fairfield Inn on the web that was about 15 miles away and booked a room. The airline told me they were not booking in hotels that did not have a shuttle so I figured it would be fine and I would take a cab after I got a bite to eat at the airport. They told me if I wanted my luggage it would be about 4 hours wait so I figured I could do without it for a night and after dinner I went to find a cab. After 40 minutes in line waiting for a cab I head off for the hotel. When it arrives at the hotel the driver dropped us off on the backside and since there were no cars in the parking lot I thought this was a good plan and I am all set. Then I turned the corner and spotted the buses leaving and the line of people out the door into the parking lot. The airlines just sent over about 80 people that all needed to be registered at the hotel and they were now ahead of me even though I did have a reservation already. So the waiting in line began with the first part the most difficult due to the fact I had no jacket and it was about 30 degrees and windy. After about 45 minutes I made it in to the lobby and started to thaw out. But it was another hour and a half before I actually got my room key. That night went pretty uneventful from there and now I sit and wait to get another cab back so I can fly out tonight. As you can see this was an unpleasant ordeal but not so much even trivial compared to other events going on in the world today. But it did make for really bummer of an ending to what was otherwise a fantastic summit. And I am sure I can look forward to some relaxing snow shoveling when I get home as well.&lt;/FONT&gt;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=The Joy's of traveling&amp;amp;body=Seen on SQLblog.com: %0A%0A%09The Joy's of traveling%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx" target="_blank" title = "Email The Joy's of traveling"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx&amp;amp;title=The+Joy%27s+of+traveling" target="_blank" title = "Submit The Joy's of traveling to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx&amp;amp;phase=2" target="_blank" title = "Submit The Joy's of traveling to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx&amp;amp;title=The+Joy%27s+of+traveling" target="_blank" title = "Submit The Joy's of traveling to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx&amp;amp;title=The+Joy%27s+of+traveling" target="_blank" title = "Submit The Joy's of traveling to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2007/03/17/the-joy-s-of-traveling.aspx&amp;amp;title=The+Joy%27s+of+traveling&amp;amp;;top=1" target="_blank" title = "Add The Joy's of traveling to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=1003" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author></entry><entry><title>What are you waiting for?</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx" /><id>http://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx</id><published>2006-11-24T18:29:00Z</published><updated>2006-11-24T18:29:00Z</updated><content type="html">&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Another question I asked at my pre-con seminar last week at PASS in Seattle troubled me somewhat. This question was “How many people currently collect Wait Stats.” Just a few people raised their hands out of about 105 in total. While you do have to keep in mind that this session was for people wanting to know more about performance monitoring it was still a very low percentage. Collecting Wait Stats is such a simple task and has virtually no overhead. Reporting on it is easy as well. So easy in fact that together with the wealth of information Wait Stats can give you there is no excuse for not collecting these figures on a regular basis. So if you are not I have to say shame on you&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I won’t go into details about how to collect or analyze these since the SQL Server Customer Advisory Team has a new web site full of information on subjects just like this and a lot more. If you haven’t checked out this site yet you should make it a priority.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is going to be one of the most popular SQL Server sites in a very short time when it comes to performance and scalability tips and documentation. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Wait Stats were just a teaser to get you interested so don’t stop there, enjoy all the great documentation.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/default.mspx"&gt;&lt;FONT color=#800080&gt;http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/default.mspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;BR&gt;&lt;div class = "shareblock"&gt;&lt;span class = "shareblockTitle"&gt;Share this post:&lt;/span&gt;&lt;span class = "shareblockLink"&gt; &lt;a href = "mailto:?subject=What are you waiting for?&amp;amp;body=Seen on SQLblog.com: %0A%0A%09What are you waiting for?%0A%0Ahttp://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx" target="_blank" title = "Email What are you waiting for?"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx&amp;amp;title=What+are+you+waiting+for%3f" target="_blank" title = "Submit What are you waiting for? to del.icio.us"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx&amp;amp;phase=2" target="_blank" title = "Submit What are you waiting for? to digg.com"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx&amp;amp;title=What+are+you+waiting+for%3f" target="_blank" title = "Submit What are you waiting for? to reddit.com"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx&amp;amp;title=What+are+you+waiting+for%3f" target="_blank" title = "Submit What are you waiting for? to DotNetKicks"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://sqlblog.com/blogs/andrew_kelly/archive/2006/11/24/367.aspx&amp;amp;title=What+are+you+waiting+for%3f&amp;amp;;top=1" target="_blank" title = "Add What are you waiting for? to Live Bookmarks"&gt;live it!&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://info.sqlblog.com/a.aspx?ZoneID=0&amp;BannerID=12&amp;AdvertiserID=1&amp;CampaignID=12&amp;Task=Get&amp;Mode=TEXT&amp;SiteID=1&amp;RandomNumber=463323" width="1" height="1" border="0"&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=367" width="1" height="1"&gt;</content><author><name>Andrew Kelly</name><uri>http://sqlblog.com/members/Andrew+Kelly.aspx</uri></author></entry></feed>