The Bit Bucket

Shortcut: Sharing query plans in SQL Server Management Studio

Currently, SQL Server query plans are stored as XML. You can see what they look like by right-clicking in any query plan in SQL Server Management Studio (SSMS), and clicking Show Execution Plan XML:

That will return a whole bunch of XML like this:

It’s important to understand that when SSMS is showing a graphical execution plan, it’s just graphically rendering some XML like the plan above.

The Properties window in SSMS is also showing details extracted from that same XML.

2018-12-20

Podcast: SQL Down Under Show 74 with guest Argenis Fernandez

Hi Folks, whenever a new version of SQL Server is starting to appear, I try to have a series of podcasts that discuss what’s happening with it. Now, SQL Server 2019 isn’t that far off so I thought it’s time to start discussing the features in it, in depth.

First up, it’s Argenis Fernandez (@DBArgenis) from the SQL Server team. Argenis provides an awesome discussion on the use of non-volatile memory systems and how he sees them as a game changer.

2018-12-19

SDU Tools: List Unused Indexes in a SQL Server Database

SQL Server databases are often littered with indexes that aren’t needed. In many cases, people won’t even remember why they were created in the first place. So I’m often checking out indexes that might be candidates for removal. One of our free SDU Tools for developers and DBAs does just that. It’s ListUnusedIndexes.

You can see how to execute it in the main image above. The procedure takes just one parameter:

2018-12-19

Never lose hope - it's all around you

It’s that time of year again when people look philosophically back at the current year, and start to think about how they’ll improve their situation in the new year. But for many, this is a very hard time of the year.

I’ve had a few friends this year who seem to have almost lost hope when they’ve ended up in poor situations.

I just wanted to make a short post to encourage you all to never lose hope. Alexander Pope said:

2018-12-18

Book Review: The Second Machine Age

One of my colleagues Orin Thomas is a prolific writer. I’ve lost count of how many detailed books he’s written, and I’ve no doubt he’s lost count as well. If you’ve worked in Microsoft-related IT for any length of time, I’m sure you’ll have read one of his books, particularly if you’ve been involved in certification. You can see a partial list of his books here.

But the other thing that amazes me about Orin is that he’s also a prolific reader. I can’t believe how many books he gets through, and he’s inspired me to get through way more. I have not the slightest doubt that being a good reader is a prerequisite for being a good writer. Every time I meet with Orin, he mentions books that I should read. I note them down, and slowly make my way through many of them.

2018-12-14

Shortcut: Missing index details in SQL Server Management Studio

I’ve mentioned before that SQL Server Management Studio (SSMS) is a good tool for analyzing queries, as much as for executing them.

In SQL Server 2005, query plans had missing index details added. When a query plan was created, SQL Server recorded that it thought it could have executed the query better, if only you’d provided it with appropriate indexes. But at that point, the suggestions weren’t very good, and the tools didn’t show them.

2018-12-13

SDU Tools: Show a number as text in SQL Server

Years ago, it was common to need to print checks (cheques) from computer systems. Fortunately checks have now pretty much disappeared in most countries. One of the challenges with printing a check, was that you needed to convert an amount of money into words. Even though checks are on the wane, it’s still important to do that on some contracts, etc.  In our free SDU Tools for developers and DBAs,  we added a function NumberAsText to do just that.

2018-12-12

SQL: Cursor types in SQL Server

When I’m running SQL Server Advanced T-SQL classes, we spend time discussing cursors. The general message is that most of the time, but not always, cursors are the wrong answer. The problem with cursors is that instead of telling SQL Server what you want it to work out (ie: declarative query), you are telling it how to work that out (ie: procedural query).

You’ll hear people say to never use cursors. This is also incorrect. There are occasions where I do use cursors. Mostly this is when I’m building utilities that do things like scripting objects in the database. I’d almost never use a cursor though, in general data processing running against SQL Server. You don’t want to be doing row by row processing against the server.

2018-12-12

Opinion: Get used to reading traces and logs before you need them

I used to do a lot of work at the operating system and network level. I was always fascinated watching people use network trace tools when they were trying to debug a problem. The challenge was that they had no idea what was normal activity on the network, and what wasn’t.

The end result of this is that they’d then spend huge amounts of time chasing down what were really just red herrings.

2018-12-11

SQL: Fields and columns, what's in a name?

Old PC style databases and tools (like Access and DBase) and most 4GL databases tended to use the words Record and Field to describe the layout of tables. Relational SQL databases use the terms Row and Column. I endlessly hear discussions about if there’s a difference, and where that lies.

Some will argue, for example, that a field is a data value within a single record or row. That would make a field more like a cell in Excel, than a column in Excel.

2018-12-10