The Bit Bucket

New Online Course: SQL Server Service Broker for Developers and DBAs

I’d love to be running Service Broker classes more often. Service Broker is one of the most powerful, yet least understood technologies in SQL Server. Many of our enterprise clients are using it and loving it.

What we tend to find though, is that we get requests from a number of interested people, spread over time, and locations. But not enough to run in-person classes in those locations.

So we decided to fix that, for this course and for a number of our other courses that have similar demand (i.e. Spatial, Replication, and more).

2019-04-16

T-SQL 101: 13 Quoting (Delimiting) Identifiers in T-SQL

If you look carefully at the following two queries in the image below:

you’ll notice there are a couple of differences. In the first query, the word Description is blue, and in the second, it isn’t blue but it has square brackets around it. The second is an example of quoting or delimiting an identifier.

In this case, the reason that the word was blue in the first query is that somewhere in SQL Server, this word is part of the syntax of the language itself. That’s much the same as SELECT or ORDER BY. So SQL Server Management Studio (SSMS) color-codes it the same way it does for the word SELECT.

2019-04-15

SQL in the City - Brisbane, Christchurch, Melbourne - Hope to see you there

I’m presenting a session on Azure DevOps for SQL Server DBAs that’s designed as an intro for data people who haven’t really worked with it before, at Red-Gate’s SQL in the City events in Brisbane (May 31), Christchurch (June 7), and Melbourne (June 14).

Looks like a fun lineup for the day, and it’d be great to catch up with you at one of those events. You can find more info here:

2019-04-12

SQL: Fix - Missing Font Options in SQL Server Management Studio (SSMS) 17.x

Ever since about version 17.3 of SQL Server Management Studio, I’ve had problems with fresh installs (as opposed to upgrades). I’ve been unable to set the fonts and colors. When I go into that dialog, I see the list as shown in the main image above.

All the normal option for windows that you can make settings for aren’t there.

On my current machine, I had just installed a v18 SSMS and it was fine. All font options, etc. were there. But I had to install v17.9.1 of SSMS side-by-side because the ssbdiagnose tool was missing on my machine. (I needed it for our new Service Broker course and v18 doesn’t install it for some reason).

2019-04-11

SDU Tools: CalculateTableLoadingOrder - follow table dependencies in T-SQL

If there is a reasonable number of tables in a SQL Server database, and I’ve also got foreign keys linking them, it can be difficult to work out the order of the dependencies. That’s a hassle when I want to load data, and for other admin functions that I might need to perform. So we’ve fixed that.

In our free SDU Tools for developers and DBAs, there’s a stored procedure called CalculateTableLoadingOrder.

2019-04-10

Power BI: AddWeekdays function for Power Query M language

In our free SDU Tools for Developers and DBAs was an AddWeekdays function. Now that was for T-SQL. Recently though, I needed to do that for Power Query. While the M language has a wonderful set of date-related functions, it didn’t have this one.

That made it time to write one. Here’s the code that’s required:

So how does it work?

Forgive the formatting to fit this window, but let’s take a quick look through it:

2019-04-09

T-SQL 101: 12 Using Statement Terminators in T-SQL

I think T-SQL is an odd language in many ways. One aspect of this is the looseness of the language. The best example of this is the way that statement terminators (i.e. the semicolons at the end of the statements) are optional.

Back in 2005, the optionality of the statement terminators was deprecated. The SQL Server team told us to start using them, because one day they’ll be required.

2019-04-08

Podcast Review: The Drop Out

I like serious investigative journalism that’s released as podcasts. I enjoyed Serial with their story about Adnan Syed, and in a similar vein there’s now The Drop Out from ABC Radio.

I’m surprised that I hadn’t heard about Elizabeth Holmes or Theranos, or at least that if I had heard about them, I hadn’t taken much notice of them. After listening to The Drop Out, I’m stunned that it hadn’t been something I already knew all about.

2019-04-05

SQL: Cannot drop the database because it is being used for replication

If you go to drop a database, and you’re told you can’t because it’s being used for replication, you might be a little confused. For example, if you check your publications and subscriptions, you might see this:

Given there aren’t any, how could the database be being used for replication? Well, each database has a property that indicates if it’s enabled for replication, even if there aren’t any publications. That’s what’s stopping you from dropping the database.

2019-04-04

SDU Tools: StartOfMonth and EndOfMonth in T-SQL

In our free SDU Tools for developers and DBAs, we have a large number of useful functions. The topic for today is two simple ones: StartOfMonth and EndOfMonth.

SQL Server 2012 added a function EOMONTH. It returns the end of the month date for any given date. I really, really don’t like abbreviations like this. There is no need to save three characters.

I asked why it wasn’t ENDOFMONTH but was told that EOMONTH was the name of the function in Excel. It’s sad to think that’s the guiding principle for T-SQL function names. I also don’t get why sometimes the words in the names are separated by underscores, and other times they aren’t. Surely END_OF_MONTH would be more readable.

2019-04-03