Using Excel and Get Data to Find Fixes in SQL Server CUs

Lately, for whatever reason, we’ve had clients running into a small rash of bugs or bug-like behavior in SQL Server; soGetData Buttonsme in the Engine, some in SSRS (the SSRS ones have been fun). In one case, it occurred a day or two after SQL Server 2016 SP1 CU3 was released, so we (I was talking to Joey about it at the time) had a list of fixes to go through.

 

This is fine and all, but when one is looking for a fix for a specific behavior (“I’ve had this bug all summer, so I want to look through every CU release to see if it’s in there”), it’s a bit of a pain to go through the whole list just scanning for the, say, Reporting Services fixes. It’s even worse if the instance is behind and you need to look through multiple CUs for something. Another scenario is if you are just reviewing a newly-released CU and really only care about fixes that pertain to the engine…you get the idea.

These lists can get long

Business Intelligence to the Rescue!

Fortunately, there are some tools built right into Excel that make this a whole lot easier than scrolling through the list in your browser. Armed with nothing more than the URL to the CU’s KB article and Excel 2016 (or a few older versions) quick work can be made of generating custom filters for this data.

Here are the steps:

In Excel 2016, click on the Data tab of the ribbon. This is where the artist formerly known as “Power Query” lives, now referred to as “Get & Transform.”

Starting with the New Query button, navigate down through the menu to From Other Sources and then From Web:

New Query | From Other Source | From Web

 

This brings up a simple little dialog that asks for a URL. Paste in the URL for the CU page you’re interested in; here, I’m using SQL 2016 SP1 CU3’s URL: https://support.microsoft.com/en-us/help/4019916/cumulative-update-3-for-sql-server-2016-sp1

Clicking OK brings up the next dialog, a security-related dialog that allows you to provide any credentials that may be needed to access the material. Of course, in this case, no specific credentials are needed, as it is a public web page. Leaving Anonymous selected here is the way to go.

Web Page Security

Clicking Connect will bring up the real meat of Power Query Get Data, where we will choose what data we want to import, and optionally do some ETL-like transformations to it.

Whenever pulling in data from a web page/table for the first time, there is a bit of experimentation that needs to happen. For example, when the “Navigator” dialog opens for the first time, there’s a big list of Tables from the web page, and no data displayed:

Select Table to load data from

What has to happen, is you need to find which of those tables contains the data on the web page you’re interested in. In our case, we’re interested in Table 0, where we can see the data we’re looking for; mainly the Fix area column:

Populated Table 0

Quick note: The reason for so many tables of other data on this page is that down towards the bottom of the page, under the “Cumulative update package file information” link/collapsed menu are a bunch of tables that contain a bunch of information about all of the files that are modified by fixes in this CU. All of those tables are available here, too.

Once the table you’re interested in is selected, we can move on. The next step could be clicking the Edit button, where you’d be able to do all kinds of transformations to the data in this table… here, we don’t need to do that, so can skip that part and go straight to loading the data.

As we’re only looking to read through this data on its own (as opposed to loading it into a Power Pivot data model), we can just click the Load button.

The end result will be a table of data in Excel that contains all the fixes in the CU:

Populated Fixes in Excel table

The best part about this, and the whole reason we’re here, is Excel’s “Auto Filter” feature works on this table (and it is already activated, even). Clicking on the arrowhead in the “Fix area” column yields this familiar pop-up menu, where all manner of sorting and filtering can be done.

Excel Auto Filter dialog

Simply check the area of the product you’re interested in from the list, and you’ll be presented with a nice short list of fixes to look through.

Fix list filtered to Heckaton

Awesome!

Re-use

But, let’s say you’ve gone through this, and you’re thinking “that was kind of a pain, and won’t really save any time for all the more often that page needs looked at.” That’s possibly a fair assessment. Since all of these CU pages are identical (for now), the extract logic stays the same, with the only thing needing to change being the source URL. Once you’ve set up this workbook once, you can save the file and modify the URL it pulls its data from when the next CU comes out, but the amount of clicking required to do that is about the same as it takes to set this up the first time, therefore I’m not sure how helpful that would be.

Probably the best thing to do is to save this file off after you’ve created it and reference it as-needed, clicking the Refresh All button on the Data tab when you open this to make sure you have current data.

Random Word Tip (#1?)

I’m full of random bits like this, but I’m not really good at pulling details out of things I do which others might not know, so they don’t come out very often. If I were better at that, I’d have more things to write about!

I admit that I’m a crazy Word Pedant™, and will lots of times go overboard on making sure things are done the “right” way. All that said though, there are still new things to discover in it. This is one of those things. With the benefit of hindsight, this is a pretty basic piece of functionality that I probably should have already had a handle on. I do like these settings, and for the type of documentation that I’m doing now, it has a real benefit.

Table Properties

Long story short, we’re after these two checkboxes in the Table Properties dialog:

Row Options shown in the Table Properties Dialog

(The Table Properties dialog is an option on the context menu if you right-click anywhere in a Table, or also the Table Tools | Layout tab of the Ribbon.)

These two options do just what they say they do:

Allow rows to break across pages. This setting is similar to the “don’t let a single sentence of a paragraph sit on a page by itself” setting (which I can’t currently find in Word 2010, so maybe you can’t control that anymore). It comes into play if there’s multiple lines of text in a table cell (or every cell in a row). It will force the whole row to break down to the next page instead of splitting the row contents across a page break.

This is good for the ETL documentation I’m working on these days, because some of the source-to-target mappings that are being documented have some pretty long descriptions and/or script bits to handle conversions & such. In a four or five column table on a portrait Letter page, some of these rows wind up pretty tall. It’s really confusing to read if these long snippets wind up broken across pages. This situation is made worse because all of the other columns’ data is back on the last page, and half of the mapping description is hanging out by itself on page two. It does mean there’s sometimes half a page left blank because of a tall row, but that’s the lesser of evils, in my opinion.

Repeat as header row at the top of each page. (Just to note, this option is also available as a button on the Table Tools | Layout tab of the Ribbon. That part of the Ribbon will show up with the cursor in a table, and this particular option is greyed out unless the cursor is in the first row of a table. That right there is a good illustration of both the blessings and the curse of the Ribbon, but I digress.) This option can be set for one or more rows at the top of the table. When set, these rows will repeat, as they are, at the top of the table as it spans from page to page. This setting is useful for obvious reasons with big tables that span multiple pages.

Example

Making up a table in Word to mimic an ETL source-to-destination mapping document will make a useful example to show what these options will do.

With a table that spans across a page break, the default behavior in Word will yield a table that looks like this:

Default Table formattingThere are a couple problems with this.The first one is how there’s a row split across pages, leaving the back half of the mapping script sitting by itself on the second page. Obviously if this is printed, the rest of it is on the page you just turned over, so it’s not that far away. If it’s on-screen, it’s even closer—just a quick scroll up. Even so, I think it’s simply better form, if you can, to keep whole rows together to make consumption of the data easier.

Likewise, if looking at just the second page, the column headings aren’t visible. Perhaps not as big of a deal with a small table, or a document where the same general table is repeated throughout, but if the table is large, or perhaps one that spans multiple pages (I’ve had some of those going on recently), it’s very convenient to be able to see the headers on each page. Think of how nice it is to Freeze Panes in Excel.

Enabling the two options discussed above on the same table will result in this table:

Word table formatted with discussed options

Now both problems have been solved. The penultimate row is no longer broken across pages—it now is forced down to the second page in its entirety, easing comprehension of its contents. Additionally, the column headers now repeated on the second page save one’s sanity for obvious reasons.

The repeated header rows are kind of “virtual” rows—you can’t even put your cursor in it. They update in real-time when the actual header row is changed, so they are always correct.

There you have it. Go forth and format tables!