<?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>Search results matching tags 'SQL Server 2008 R2', 'resource database', and 'SQL Server 2008'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SQL+Server+2008+R2,resource+database,SQL+Server+2008&amp;orTags=0</link><description>Search results matching tags 'SQL Server 2008 R2', 'resource database', and 'SQL Server 2008'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Peeking under the hood : what bits have changed in SQL Server 2008 R2?</title><link>http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/22/peeking-under-the-hood-what-bits-have-changed-in-sql-server-2008-r2.aspx</link><pubDate>Sat, 22 Aug 2009 15:34:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:16187</guid><dc:creator>AaronBertrand</dc:creator><description>&lt;p&gt;We know what new features are available in SQL Server 2008 R2: data-tier applications (still with that unfortunate and poorly-chosen acronym, DAC), control point explorer, dashboard viewpoints, report builder 3.0, Unicode compression, StreamInsight, yada yada.&amp;nbsp; To me, at this early point in the release cycle, these features are, well, boring -- mostly because they are not yet fully implemented yet, or in a few cases, because I just haven't had the time to dig into them yet.&amp;nbsp; I do plan on doing some further investigation into the performance impact of Unicode compression, and provide you with some metrics that might help you determine if this might be a useful feature for you.&amp;nbsp; In the meantime, I wanted to get my hands dirty.&amp;nbsp; I'm not talking about a little grease or a smudge of chocolate : I'm talking REAL dirty.&amp;nbsp; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;I installed an instance of SQL Server 2008, and left it at RTM, in spite of setup's assurance that RTM has compatibility issues with Windows Server 2008 R2.&amp;nbsp; I then set up a second instance of SQL Server 2008, and applied SP1 + CU3.&amp;nbsp; Finally, I set up an instance of SQL Server 2008 R2.&amp;nbsp; To summarize, my setup looks like this:&lt;/p&gt;


&lt;table class="MsoNormalTable" style="margin:auto auto auto 0.45in;width:5.5in;border-collapse:collapse;" cellpadding="3" cellspacing="0"&gt;

&lt;tr&gt;
  &lt;th style="border:1pt solid;"&gt;&amp;nbsp;Instance&lt;/th&gt;
  &lt;th style="border:1pt solid;"&gt;&amp;nbsp;Description&lt;/th&gt;
  &lt;th style="border:1pt solid;"&gt;&amp;nbsp;Version&lt;/th&gt;
&lt;/tr&gt;

&lt;tr&gt;
  
&lt;td style="border:1pt solid;"&gt;&amp;nbsp;\SQL2008A
  &lt;/td&gt;

&lt;td style="border:1pt solid;"&gt;&amp;nbsp;SQL Server 2008 RTM&lt;/td&gt;

&lt;td style="border:1pt solid;"&gt;&amp;nbsp;10.0.1600.22
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
  
&lt;td style="border:1pt solid;"&gt;&amp;nbsp;\SQL2008B
  &lt;/td&gt;

&lt;td style="border:1pt solid;"&gt;&amp;nbsp;SQL Server 2008 SP1+ CU3&lt;/td&gt;

&lt;td style="border:1pt solid;"&gt;&amp;nbsp;10.0.2723.0
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
  
&lt;td style="border:1pt solid;"&gt;&amp;nbsp;\SQL2008R2
  &lt;/td&gt;

&lt;td style="border:1pt solid;"&gt;&amp;nbsp;SQL Server 2008 R2&lt;/td&gt;

&lt;td style="border:1pt solid;"&gt;&amp;nbsp;10.50.1092
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Now that I have the environment set up, I'll explain what I'm going to do: compare versions of the mssqlsystemresource database.&amp;nbsp; I've always been fascinated by the resource database, and the fact that you can't gain access to it at all, at least under normal circumstances.&amp;nbsp; It has always felt like this taboo thing, like you do not talk about Fight Club, and I constantly wonder what they put in there under lock and key that they couldn't put in master.&amp;nbsp; Back when SQL Server 2005 first introduced this "hidden" database, it wasn't a very well-kept secret that you could shut down SQL Server, make a copy of the MDF and LDF files, and then attach them under a different name; voila, a user database with all the resource database code and data.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;So, I go to the Services applet (one way to get there is through Control Panel | Administrative Tools) and systematically bring down the SQL Server services for the three instances noted above.&amp;nbsp; Once the services are stopped successfully, I go into the following folders (the paths might be different for you, depending on your data drive and if you customized your Instance ID separate from your instance name):&lt;/p&gt;

&lt;p style="margin-left:40px;"&gt;&lt;/p&gt;

&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008A\MSSQL\Binn\&lt;br&gt;C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008B\MSSQL\Binn\&lt;br&gt;C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\Binn\&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;In each of these folders in Windows Explorer, I hold Shift and right-click on the Binn folder, select "Open command window here", and copy the following files:&lt;/p&gt;

&lt;p style="margin-left:40px;"&gt;&lt;/p&gt;

&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;copy mssqlsystemresource.mdf resourcecopy.mdf &lt;br&gt;copy mssqlsystemresource.ldf resourcecopy.ldf &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Then I start all three instances, open a query window for each, and run the following (replacing %PATH% in each case with the relevant path listed above):&lt;/p&gt;

&lt;p style="margin-left:40px;"&gt;
&lt;/p&gt;

&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;&lt;font color="blue"&gt;CREATE&amp;nbsp;DATABASE&amp;nbsp;&lt;/font&gt;&lt;font color="black"&gt;ResourceCopy&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;ON&lt;br&gt;&lt;/font&gt;&lt;font color="gray"&gt;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;FILENAME&amp;nbsp;&lt;/font&gt;&lt;font color="gray"&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color="red"&gt;'%PATH%\resourcecopy.mdf'&lt;br&gt;&lt;/font&gt;&lt;font color="gray"&gt;)&lt;br&gt;&lt;/font&gt;&lt;font color="magenta"&gt;LOG&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;ON&lt;br&gt;&lt;/font&gt;&lt;font color="gray"&gt;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="blue"&gt;FILENAME&amp;nbsp;&lt;/font&gt;&lt;font color="gray"&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color="red"&gt;'%PATH%\resourcecopy.ldf'&lt;br&gt;&lt;/font&gt;&lt;font color="gray"&gt;)&lt;br&gt;&lt;/font&gt;&lt;font color="blue"&gt;FOR&amp;nbsp;ATTACH&lt;/font&gt;&lt;font color="gray"&gt;;&lt;/font&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;I probably could have whipped up a script to perform all of these things for me, but it might have taken just as long (or probably longer).&amp;nbsp; So here we are.&lt;/p&gt;

&lt;p&gt;Now I have three very accessible copies of the resource database, and I just need a means to compare them.&amp;nbsp; In this case I am going to use the tool I use in my everyday work, &lt;a href="http://www.red-gate.com/products/SQL_Compare/index.htm" title="http://www.red-gate.com/products/SQL_Compare/index.htm" target="_blank"&gt;Red-Gate SQL Compare&lt;/a&gt;.&amp;nbsp; I'm not trying to play favorites; it is just the tool I've been using since day one.&amp;nbsp; Any capable product will do the job, of course; I provide a very comprehensive list of alternatives in my blog post on &lt;a href="http://www.onetooneinteractive.com/otocorporate-posts/2009/06/01/the-cost-of-reinventing-the-wheel/?showin=otolabs" title="http://www.onetooneinteractive.com/otocorporate-posts/2009/06/01/the-cost-of-reinventing-the-wheel/?showin=otolabs" target="_blank"&gt;the cost of reinventing the wheel&lt;/a&gt; - mostly just to illustrate that there are so many products to choose from, that you really should try several to see which works best for you (if you're not already set in your ways, like me).&lt;/p&gt;

&lt;p&gt;In SQL Compare, you choose File | New Project, and pick the two databases you want to compare, as follows: &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://sqlblog.com/files/folders/16199/download.aspx" title="New Project dialog" target="_blank"&gt;&lt;img src="http://sqlblog.com/files/folders/16199/download.aspx" border="1" width="600"&gt;&lt;/a&gt;&lt;br&gt;&lt;font color="#999999"&gt;&lt;i&gt;New Project dialog&lt;/i&gt;&lt;/font&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;After clicking Compare Now, the tool brings back up to four sets of objects: those that are in both but have changed, those that are only in the left database, those that are only in the right database, and then the set of identical objects.&amp;nbsp; For each object, when you highlight it, the bottom pane will show the code on each side, and highlight the differences.&amp;nbsp; (If you want a quick way to scroll through a bunch of objects and view their definition in any database, just compare it to an empty database.&amp;nbsp; This can be much less tedious than writing your own script that extracts them all, or right-click each object from Object Explorer.)&lt;/p&gt;

&lt;p&gt;Anyway, here are the results.&amp;nbsp; I'm not going to go through each and every change, but I will highlight the parts that I found interesting.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://sqlblog.com/files/folders/16200/download.aspx" title="Differences in 2008 and 2008 R2 : resource database" alt="Differences in 2008 and 2008 R2 : resource database" border="1" height="1195" width="777"&gt; &lt;br&gt;&lt;i&gt;&lt;font color="#000066"&gt;&lt;font color="#999999"&gt;Differences in 2008 and 2008 R2 : resource database&lt;/font&gt;&lt;br&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;A lot of changes, but several of them I write off almost immediately as uninteresting.&amp;nbsp; For example, all of the sp_MS changes around replication and log reading are just the tightening up of a filter, adding a clause that prevents pulling rows from MSdistribution_history where the comments column does not start with '&amp;lt;stats state'.&amp;nbsp; Yawn.&amp;nbsp; Some obvious bug fixes in the data compression procedure (issues with clustered index) and to sp_help (they were missing BIGINT as a type that has some tie to precision/scale), and a new column in the catalog view sys.change_tracking_databases (max_cleanup_version). &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Even more interesting than the deltas were a couple of new objects.&amp;nbsp; We see functions that would be extremely useful if we could call them ourselves, such as fn_getVolumeFreeSpace and fn_getProcessorUsage.&amp;nbsp; These are obviously called by other system functions that can access the MpuSqlClrWrapper assembly, as when I try to call them as a &lt;strike&gt;mere peon&lt;/strike&gt; sysadmin, I get the following error:&lt;/p&gt;


&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;color:red;"&gt;Msg 15351, Level 16, State 1, Line 1&lt;br&gt;The CLR procedure/function/type being signed refers to an assembly that is not signed either&lt;br&gt;by a strong name or an assembly. &lt;br&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;But this seems to be paving the way for integrated CLR objects that we may someday be able to use without writing our own assemblies (who wouldn't like to see RegEx included in the box)? &lt;br&gt;&lt;/p&gt;



&lt;p&gt;Another thing I noticed is that there are some funny coding habits revealed in system objects.&amp;nbsp; I remember working with a guy who always wrote code like, "WHERE 50 = CustomerID," and it drove me batty.&amp;nbsp; Here in the code for sys.sp_dropmessage, I see this doozie: &lt;br&gt;&lt;/p&gt;
&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;... &lt;font color="blue"&gt;AND&lt;/font&gt; 0 &lt;font color="gray"&gt;=&lt;/font&gt; &lt;font color="magenta"&gt;SERVERPROPERTY&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="red"&gt;'IsSingleUser'&lt;/font&gt;&lt;font color="gray"&gt;)&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;That just makes my head spin.&amp;nbsp; (Funny enough, the guy I worked with now works for MS, but not in the SQL Server group, so I'm fairly confident the code is not his.)&amp;nbsp; It would make much more sense, at least to me, as:&lt;/p&gt;


&lt;table bgcolor="#eeeeee" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;pre style="padding:10px 20px;-moz-background-clip:border;-moz-background-origin:padding;font-size:12px;font-family:consolas,lucida console,courier new,courier;-moz-background-inline-policy:continuous;"&gt;... &lt;font color="blue"&gt;AND&lt;/font&gt; &lt;font color="magenta"&gt;SERVERPROPERTY&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="red"&gt;'IsSingleUser'&lt;/font&gt;&lt;font color="gray"&gt;)&lt;/font&gt; &lt;font color="gray"&gt;=&lt;/font&gt; 0&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;I guess I'm just a formula/column/variable/defined thing on the left, and constant/less known thing on the right kind of guy.&amp;nbsp; I would rather hear the juicy part last, e.g. "my father's flight arrives at 6 PM" vs. "at 6 PM is when my father's flight arrives."&amp;nbsp; Which version is more memorable, so that you'll show up at the airport on time?&amp;nbsp; To each his/her own, I guess, but I'm afraid that if I was in there writing some of this code I'd be doing a lot of, er, constructive edits.&amp;nbsp; :-)&lt;/p&gt;

&lt;p&gt;I also compared the two 2008 instances, just because I was curious
what type of changes are made to the resource database in service packs
and cumulative updates.&amp;nbsp; As it turns out: a lot.&amp;nbsp; There were 34 changed
objects (but no new objects) between RTM and SP1 CU3.&amp;nbsp; Some of these
objects overlapped with the objects changed above, but some didn't.&amp;nbsp;
That seemed strange at first, but then I realized, of course, that a
lot of the public 2008 fixes were made *after* the R2 code was branched
off, so many of those updates simply haven't made it into that line
yet.&amp;nbsp; Here is the graphical output:&lt;/p&gt;&lt;p&gt;&lt;img src="http://sqlblog.com/files/folders/16201/download.aspx" title="Differences in 2008 RTM and 2008 SP1 CU3 : resource database" alt="Differences in 2008 RTM and 2008 SP1 CU3 : resource database" border="1" height="1115" width="775"&gt;&lt;br&gt;&lt;i&gt;&lt;font color="#999999"&gt;Differences in 2008 RTM and 2008 SP1 CU3 : resource database&lt;/font&gt;&lt;/i&gt; &lt;br&gt;&lt;/p&gt;&lt;p&gt;Most of the changes were already discussed above; but there were a couple missing (e.g. the fixes to sp_help and the new column in sys.change_data_tracking).&amp;nbsp; But there are also a couple of fixes that did not yet make it into 2008 R2; the most interesting deltas to me are the ones where they use stuff that we can't use.&amp;nbsp; For example, sp_unbindefault and sp_unbindrule make calls to EXEC %%ColumnEx() and EXEC %%System().FireTrigger()... we obviously can't call these ourselves, but it's interesting to see how and when these system functions are used, and what kind of problems get uncovered over time (in this case, the code in RTM hard-coded a column_id of 1, whereas a fix in SP1 or a CU made it pass in the @col_id value that is determined just before this block).&lt;br&gt;&lt;/p&gt;

&lt;p&gt;For fun, I also compared the system databases msdb and master between 2008 RTM and 2008 R2.&amp;nbsp; Nothing too exciting here... most of the changes are in certificates, though msdb has a few new utility roles.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://sqlblog.com/files/folders/16197/download.aspx" title="Differences in 2008 and 2008 R2 : master database" alt="Differences in 2008 and 2008 R2 : master database" border="1" height="463" width="681"&gt; &lt;br&gt;&lt;font color="#999999"&gt;&lt;i&gt;Differences in 2008 and 2008 R2 : master database&lt;/i&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://sqlblog.com/files/folders/16198/download.aspx" title="Differences in 2008 and 2008 R2 : msdb database" alt="Differences in 2008 and 2008 R2 : msdb database" border="1" height="443" width="690"&gt;&lt;br&gt;&lt;font color="#999999"&gt;&lt;i&gt;Differences in 2008 and 2008 R2 : msdb database&lt;/i&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Did I learn a lot from this exercise?&amp;nbsp; Not really.&amp;nbsp; But I hope I demonstrated that it doesn't take much to dig into the product and examine deltas (or just effortlessly look at the resource database code, or any database code really).&lt;br&gt;&lt;/p&gt;</description></item></channel></rss>