<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Andrew Kelly : Documentation</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx</link><description>Tags: Documentation</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Finding IP Addresses With CMS</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2011/07/25/finding-ip-addresses-with-cms.aspx</link><pubDate>Mon, 25 Jul 2011 20:14:29 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:37306</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>2</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/37306.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=37306</wfw:commentRss><description>&amp;#160; I was just tasked with putting together a list of all the IP Addresses of the SQL Servers that one of my clients deals with on a daily basis. In this case there was over 30 of them and while I could ping each one individually I found an easier...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2011/07/25/finding-ip-addresses-with-cms.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37306" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Central+Management+Servers/default.aspx">Central Management Servers</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Tips+_2600_+Tricks/default.aspx">Tips &amp; Tricks</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Trivia/default.aspx">Trivia</category></item><item><title>The latest edition of the SolidQ Journal is now available</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2011/07/11/the-latest-edition-of-the-solidq-journal-is-now-available.aspx</link><pubDate>Mon, 11 Jul 2011 23:57:44 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36788</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/36788.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=36788</wfw:commentRss><description>&amp;#160; The SolidQ Journal is published monthly by SolidQ and packed with lots of good information related to SQL Server and related topics. If you haven’t already signed up to get these each month then have a look here .&amp;#160; It’s a free resource that...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2011/07/11/the-latest-edition-of-the-solidq-journal-is-now-available.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=36788" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/SolidQ+Journal/default.aspx">SolidQ Journal</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Tips+_2600_+Tricks/default.aspx">Tips &amp; Tricks</category></item><item><title>SQL Server 2008 R2 Analysis Services Operations Guide</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2011/06/01/sql-server-2008-r2-analysis-services-operations-guide.aspx</link><pubDate>Wed, 01 Jun 2011 22:03:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36029</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/36029.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=36029</wfw:commentRss><description>Some members of the SQL CAT Team just released an Operations Guide for SQL 2008 R2 Analysis Services that can be found here . While I am not a SSAS person by any means this looks pretty cool and worth while for anyone who does work with it so have a look....(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2011/06/01/sql-server-2008-r2-analysis-services-operations-guide.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=36029" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/2008+R2/default.aspx">2008 R2</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Best+Paractices/default.aspx">Best Paractices</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category></item><item><title>New Book on the Query Optimizer</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2011/04/09/new-book-on-the-query-optimizer.aspx</link><pubDate>Sat, 09 Apr 2011 22:30:04 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:34772</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/34772.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=34772</wfw:commentRss><description>&amp;#160; A friend of mine Benjamin Nevarez has written a book on the inner workings of the Query Optimizer and it was just released. I read a preview and was definitely impressed so I expect the full version to be just as good. More details can be found...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2011/04/09/new-book-on-the-query-optimizer.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=34772" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Books/default.aspx">Books</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Query+Optimizer/default.aspx">Query Optimizer</category></item><item><title>System Center Advisor Collection Details</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2011/04/07/system-center-advisor-collection-details.aspx</link><pubDate>Thu, 07 Apr 2011 03:39:26 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:34716</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/34716.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=34716</wfw:commentRss><description>&amp;#160; The System Center Advisor team (formally Project Atlanta) now lists some pre-release documentation on exactly what information they collect and how you can view it before it gets uploaded. So if you are wondering what they collect you can have...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2011/04/07/system-center-advisor-collection-details.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=34716" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Best+Paractices/default.aspx">Best Paractices</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/System+Center+advisor/default.aspx">System Center advisor</category></item><item><title>Project Atlanta Has a New Name</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2011/03/22/project-atlanta-has-a-new-name.aspx</link><pubDate>Tue, 22 Mar 2011 17:57:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:34326</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/34326.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=34326</wfw:commentRss><description>&amp;#160; Brad Anderson just completed a keynote in Las Vegas at the Microsoft Management Summit 2011 and announced the new name for what was originally called Project Atlanta. Dot da da dah… And the new name is:&amp;#160; System Center Advisor .&amp;#160; You can...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2011/03/22/project-atlanta-has-a-new-name.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=34326" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Best+Paractices/default.aspx">Best Paractices</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Maintenance/default.aspx">Maintenance</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Utilities/default.aspx">Utilities</category></item><item><title>The January 2011 Edition of the SolidQ Journal is Out</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2011/01/17/the-january-2011-edition-of-the-solidq-journal-is-out.aspx</link><pubDate>Mon, 17 Jan 2011 18:21:45 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:32680</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/32680.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=32680</wfw:commentRss><description>&amp;#160; The latest edition of the SolidQ Journal is now available online at http://www.solidq.com/sqj/Pages/Home.aspx . Enjoy, Andrew J. Kelly...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2011/01/17/the-january-2011-edition-of-the-solidq-journal-is-out.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=32680" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/SolidQ+Journal/default.aspx">SolidQ Journal</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Tips+_2600_+Tricks/default.aspx">Tips &amp; Tricks</category></item><item><title>Latest SolidQ Journal Plus Giveaways</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2010/12/17/latest-solidq-journal-plus-giveaways.aspx</link><pubDate>Fri, 17 Dec 2010 19:34:33 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:31726</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/31726.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=31726</wfw:commentRss><description>&amp;#160; You can find the latest edition of the SolidQ Journal here that is always good reading but if you register over the next 3 weeks you may be eligible for a prize including:&amp;#160; One $500 Amazon gift card and 5 $150 gift cards; books from Itzik...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2010/12/17/latest-solidq-journal-plus-giveaways.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=31726" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/SolidQ+Journal/default.aspx">SolidQ Journal</category></item><item><title>White Paper on Parallel Processing</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2010/12/10/white-paper-on-parallel-processing.aspx</link><pubDate>Fri, 10 Dec 2010 15:24:35 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:31510</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/31510.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=31510</wfw:commentRss><description>&amp;#160; I just ran across what I think is a newly published white paper on parallel&amp;#160; processing in SQL Server 2008 R2. The date is October 2010 but this is the first time I have seen it so I am not 100% sure how new it really is. Maybe you have seen...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2010/12/10/white-paper-on-parallel-processing.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=31510" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Parallelism/default.aspx">Parallelism</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Performance/default.aspx">Performance</category></item><item><title>SQL Server 2008 R2 System Views Map Poster</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2010/12/08/sql-server-2008-r2-system-views-map-poster.aspx</link><pubDate>Thu, 09 Dec 2010 01:21:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:31459</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>2</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/31459.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=31459</wfw:commentRss><description>&amp;#160; The latest SQL Server 2008 R2 systems views map poster is available here: 2008 R2 Poster It’s available in a pdf or xps format so have fun with it. &amp;#160; Andy...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2010/12/08/sql-server-2008-r2-system-views-map-poster.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=31459" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/2008+R2/default.aspx">2008 R2</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Trivia/default.aspx">Trivia</category></item><item><title>Updates for Some 2008 Tools</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2010/06/20/updates-for-some-20008-tools.aspx</link><pubDate>Sun, 20 Jun 2010 03:03:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:26294</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>3</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/26294.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=26294</wfw:commentRss><description>There have been a few releases over the last few days for some SQL Server 2008 tools that you may be interested in. The first one is the 2008 R2 Best Practices Analyzer found here: http://blogs.msdn.com/b/sqlreleaseservices/archive/2010/06/19/sql-server-2008-r2-best-practices-analyzer-is-now-available.aspx...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2010/06/20/updates-for-some-20008-tools.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=26294" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/2008+R2/default.aspx">2008 R2</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Best+Paractices/default.aspx">Best Paractices</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category></item><item><title>Trace Flag Groupings</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2009/06/21/trace-flag-groupings.aspx</link><pubDate>Sun, 21 Jun 2009 15:56:52 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:14801</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/14801.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=14801</wfw:commentRss><description>I just saw a news group post by Paul Randal in which he explained how trace flags were grouped into certain categories and thought others may find this interesting as well. Please note that Paul stated that these are from memory so they may not be 100%...(&lt;a href="http://sqlblog.com/blogs/andrew_kelly/archive/2009/06/21/trace-flag-groupings.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=14801" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Trivia/default.aspx">Trivia</category></item><item><title>What time do you have?</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2008/12/20/what-time-do-you-have.aspx</link><pubDate>Sat, 20 Dec 2008 13:12:43 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:10661</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>6</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/10661.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=10661</wfw:commentRss><description>&lt;p&gt;The way in which SQL Server has treated Time has been a very misunderstood subject for as long as I can remember. The largest part of that was the fact that SQL Server was only accurate to 3.33ms. I would like to point you to an excellent article on this and other details surrounding Datetime in SQL Server by Tibor Karaszi found here:&amp;#160; &lt;a title="http://www.karaszi.com/SQLServer/info_datetime.asp" href="http://www.karaszi.com/SQLServer/info_datetime.asp"&gt;http://www.karaszi.com/SQLServer/info_datetime.asp&lt;/a&gt;&amp;#160; Well now with the release of SP3 for SQL Server 2005 (and of course SQL 2008 as well) SQL Server no longer uses the inaccurate techniques associated with the RDTSC component of Windows. Since there is a lot to explain about how this all works I will again point you to another link which goes into much greater detail.&amp;#160; &lt;a title="http://blogs.msdn.com/psssql/archive/2008/12/16/how-it-works-sql-server-no-longer-uses-rdtsc-for-timings-in-sql-2008-and-sql-2005-service-pack-3-sp3.aspx" href="http://blogs.msdn.com/psssql/archive/2008/12/16/how-it-works-sql-server-no-longer-uses-rdtsc-for-timings-in-sql-2008-and-sql-2005-service-pack-3-sp3.aspx"&gt;http://blogs.msdn.com/psssql/archive/2008/12/16/how-it-works-sql-server-no-longer-uses-rdtsc-for-timings-in-sql-2008-and-sql-2005-service-pack-3-sp3.aspx&lt;/a&gt;&amp;#160; I for one say it is about time:).&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=10661" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Performance/default.aspx">Performance</category></item><item><title>Debug button in SSMS 2008</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2008/09/17/debug-button-in-ssms-2008.aspx</link><pubDate>Wed, 17 Sep 2008 20:44:59 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:8952</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>6</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/8952.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=8952</wfw:commentRss><description>&lt;p&gt;How many people are tired of accidentally hitting the toolbar button with the &lt;font color="#008000"&gt;green&lt;/font&gt; triangle on it when trying to run a query in the Query Editor only to get into the &lt;font color="#ff0000"&gt;debug&lt;/font&gt; mode?&amp;#160; If you are like me then I bet a lot of you:).&amp;#160; It only seems natural to hit the &lt;font color="#008000"&gt;Green&lt;/font&gt; button to run something right?&amp;#160; Especially since it is right next to the execute button to begin with. Maybe if you are more of a developer and use Visual Studio a lot its not so bad. Well I got tired of it real quick so I simply removed it from the toolbar altogether and no longer have to think about it.&amp;#160; For those few times you really want to debug the script you can still access it from the menu or by hitting Alt - F5.&amp;#160; These are such simple solutions but we tend to forget about them so this is just a reminder that you can control your SSMS life after all:).&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=8952" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Trivia/default.aspx">Trivia</category></item><item><title>When a Function is indeed a Constant</title><link>http://sqlblog.com/blogs/andrew_kelly/archive/2008/03/01/when-a-function-is-indeed-a-constant.aspx</link><pubDate>Sat, 01 Mar 2008 16:19:19 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5382</guid><dc:creator>Andrew Kelly</dc:creator><slash:comments>6</slash:comments><comments>http://sqlblog.com/blogs/andrew_kelly/comments/5382.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/andrew_kelly/commentrss.aspx?PostID=5382</wfw:commentRss><description>&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;img src="http://sqlblog.com/aggbug.aspx?PostID=5382" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/Tips+_2600_+Tricks/default.aspx">Tips &amp; Tricks</category><category domain="http://sqlblog.com/blogs/andrew_kelly/archive/tags/TSQL/default.aspx">TSQL</category></item></channel></rss>