The Bit Bucket

Book Review: The Happy Mind

Over the years, I’ve been really interested in what makes people happy in life. I’m always fascinated by people who think that wealth, products, properties, the latest handbag or car, new partner, etc. will make them happy. I’m sure the media has tried to tell them that, but it’s never been true.

I’ve had friends all colleagues all across the wealth spectrum, and I can say without any doubt in my mind, that some of the richest people I know are also some of the most unhappy. Worse, I’ve seen money destroy families so many times.

2019-04-30

T-SQL 101: 15 Using column and table aliases in SQL Server queries

Look carefully at the following queries:

I’ve shown several examples here of what are called aliases. There are two basic types of aliases.

Column Alias

In the first query, I’ve used a column alias. I wanted to query the Description column in the dbo.Products table but I wanted the column called ProductName instead. So I follow the column with the word AS and then the name I want to use for the alias.

2019-04-29

Book Review: Why we get fat and what to do about it by Gary Taubes

Weight has been an area of interest for me for a very long time, given my struggles with it. All throughout the 1980s, I wish I’d known what I do know now. Gary Taube’s book Why we get fat and what to do about it was a seminal work in this area, helping to remove the nonsense that’s been peddled as “science” and “medicine” for decades.

I was already pretty much across most of Gary’s work before I listened to this as an audiobook, but it helped me to see where much of his thinking had come from.

2019-04-26

Fixing locking and blocking issues in SQL Server - Part 2 - RCSI

This is part 2 in a series of posts:

  • Part 1 covered being sure there is a locking and blocking issue

In part 1, I talked about pseudo locking and blocking issues that come from having queries running too long. I said that before you start fixing any locking and blocking issues, that you first need to make sure your queries are running fast. Today I want to discuss RCSI.

2019-04-25

SDU Tools: Using T-SQL to find operating system versions, locales, SKUs, and configuration

When I’m writing utility scripts for SQL Server, I often need to make decisions or report on, details of the operating system that I’m running on. Unfortunately, SQL Server doesn’t have views that return this sort of information.

In our free SDU Tools for developers and DBAs, we added a series of views to help.

OperatingSystemConfiguration has details of OperatingSystemRelease, OperatingSystemName, ServicePackLevel, OperatingSystemSKU, OperatingSystemSKUName, and LanguageName.

OperatingSystemVersions has details of OS_Family, OS_Version, and OS_Name.

2019-04-24

Another new online course: Protecting SQL Server Data with Encryption

We all see news articles talking about how company after company exposed private details of their clients, customers, and sometimes, even staff. In so many cases, a reasonable approach to encryption would have avoided these issues. Time and again though, I see people doing dodgy work on protecting their data; some even trying to roll their own protection.

Don’t do this!

Encryption is one of the most important yet least understood technologies in SQL Server. It’s improved so much over the years and 2019 makes it even better.

2019-04-23

T-SQL 101: 14 Using two part names for SQL Server tables and other objects

If you look carefully at the following simple query:

you’ll notice that I didn’t just say FROM Cinemas, I said FROM dbo.Cinemas. The “dbo.” part is the name of the schema. I talked about schemas in an earlier post. And all through these T-SQL 101 blog posts, I keep mentioning that you should always use the schema name as well as the object name.

By why?

[caption id=“attachment_2806” align=“alignnone” width=“312”] Image by Ken Treloar[/caption]

2019-04-22

SQL: Do Indexed Views really require Enterprise Edition of SQL Server?

According to Wikipedia, Betteridge’s law of headlines is an adage that states: “Any headline that ends in a question mark can be answered by the word no.” In this case, they’re correct because the answer is no. But as with most things in this industry, there are subtle issues with that answer.

In SQL Server, a view is just a SELECT statement that’s been given a name. That’s pretty much it. No data is stored, and every time you access the view, the query optimizer expands the view into the surrounding query. By the time you get to an execution plan, the view is nowhere to be found.

2019-04-19

SQL: Fixing Locking and Blocking Issues in SQL Server - Part 1

I get lots of requests to help customers with their SQL Server systems. Many, many requests start with customers asking me if I can help them fix their blocking issues. Most customers aren’t actually aware of true blocking issues. Invariably what they mean, is that they’ve started to have deadlocks and things are blowing up.

[caption id=“attachment_4816” align=“alignnone” width=“384”]Awesome image by Jens Johnsson Awesome image by Jens Johnsson[/caption]

Is blocking really the issue?

I always start by working out if they really have a blocking issue. When I see performance problems, after eliminating obvious hardware and configuration issues, I’d say the issues fall into these buckets:

2019-04-18

SDU Tools: All the Versions of SQL Server using SQLServerProductVersions

I can’t tell you over the years how many times I’ve gone searching for details of a SQL Server build and/or related knowlegebase article. There are some sites that provide much of this, but I’d like to have it in a programmatic form. I can easily then use it in utilities and in my SQL scripts.

In our free SDU Tools for developers and DBAs, we added a view and a number of functions to help with this. The primary one is a view called SQLServerProductVersions.

2019-04-17