The Bit Bucket

SDU Podcast: Show 73 with Principal Architect Bob Ward

I’ve known Bob Ward for almost as long as I’ve been involved with SQL Server. (I first started in 1992). Bob is one of the constants in the SQL Server team, is deeply technical, and his continuing passion for the product is apparent.

I’ve been wanting to get Bob onto  a podcast for a long time and we finally managed to do so today.

Bob is currently a principal architect with the SQL Server engineering team, focused on architecture, customer success, and technical evangelism of SQL Server.

2017-12-09

SDU Tools: Split a Delimited String (like a CSV) Into Columns Using T-SQL

I recently wrote about the tool we provide for splitting T-SQL delimited strings (like CSVs or comma-delimited strings). It outputs a row for every value.

Sometimes, however, I’m asked how I can get each value out into a separate column. Now that’s a little trickier without dynamic code because SQL Server wants to know the output metadata of the statement. SQL Server wants to know in advance what the output columns are called and what their data types are. This is especially important if you want to consume the output of the function in tools like SQL Server Integration Services (SSIS) or Biztalk.

2017-12-08

Shortcut: Using Templates in SQL Server Management Studio (SSMS)

A week or so ago, I wrote about how to use Snippets in SQL Server Management Studio (SSMS) when you can’t remember the syntax of how to create objects in T-SQL.

Snippets were added reasonably recently compared to templates, which are more appropriate when you are creating an entire script file for a new object. They are easy to use too yet because they don’t appear on the screen by default, many people don’t even realize that they are there. Let’s take a look.

2017-12-07

SDU Tools: New T-SQL Statement: STRING_SPLIT plus Split Delimited String Tool

I’ve mentioned that I love it when SQL Server gets new T-SQL functionality.

A useful function that was added in SQL Server 2016 was STRING_SPLIT. You can see it in action in the main image for this post.

It’s another function that is great as far as it goes, but when I was a kid, this would be described as “nice try but no cigar”.

It works, and it’s fast, so what’s missing. I think two things:

2017-12-06

Opinion: Don't Design Databases for One Version of One App

I’ve pointed out in previous blog posts that I’m not a fan of ORMs. What I’m even less of a fan of is code-first design, particularly in combination with an ORM like the Entity Framework.

It might seem cool and shiny and if you are just whipping up a small proof of concept or test app, please feel free to do it, but the minute you think of doing it for enterprise systems, just don’t. And if you have colleagues wanting to do this, please just say no.

2017-12-05

SQL: Odd TRY_CAST and TRY_CONVERT Behavior

Here’s a quick T-SQL test for you.

Without looking below to see the answer first, try to guess what each of these statements will produce as output:

And to slightly distract you from checking out the answers yet, here is another wise-looking owl who is thinking about the answers, and warning you not to look further down the page yet:

Anyway, here’s what happens when you run this T-SQL in SQL Server:

2017-12-04

SDU Tools: Proper Case and Title Case (ie Don't Shout at Me)

When writing emails or online text, it’s become common to see UPPER CASE TEXT AS A FORM OF SHOUTING.

Yet I see IT systems every day that still have text that humans are meant to read in all upper-case or all lower-case. Please don’t do that to your users.

But how do you fix text like that? We have a tool for that.

The SDU Tools collection has a ProperCase function and a TitleCase function that you can use in T-SQL and stop your SQL Server based applications from shouting at your users.

2017-12-01

Shortcut: Replace Tabs with Spaces and do Macro-like work in SSMS using Regular Expressions

There are so many useful things in SQL Server Management Studio (SSMS) and daily, I come across users who aren’t aware of common useful functions.

A request that I hear all the time, is “I don’t like tabs but insert name of annoying colleague here decided he likes to use them. How do I remove them?” Now SSMS allows you to choose to use spaces instead of tabs (in Tools > Options) but that doesn’t fix existing tabs.

2017-11-30

SDU Tools: List Mismatched Data Types

I might be somewhat anal when it comes to database design. (Probably almost any type of coding). Perhaps it’s a mild form of OCPD-behavior, but inconsistency frustrates me. (I’m told that OCPD is the correct term, and that people often apply OCD to that behavior incorrectly).

Worse, inconsistency leads to nasty, hard-to-find errors and your applications become more and more fragile.

If I’m holding an email address and I define it as 70 characters in one place, 100 in another, and 160 in yet another, I have the chance of random failures when I’m moving data around or assigning values from place to place. (For email addresses, I recently discussed why they should be 320 characters anyway).

2017-11-29

Opinion: Don't just hire clones of yourself

Many years back, I was invited to chair a course accreditation panel for a local TAFE (Technical and Further Education) course. They had started to offer a computing-related 3 year diploma, and the hope was that it wasn’t too far below the 3 year degrees offered at local universities. One part of that accreditation process involved me discussing the course with the staff members who were teaching it.

After talking to almost all the staff, what struck me was how similar they all were. In the requirements for the course, there was a standard that each staff member needed to meet, but there was also a requirement for the group of staff to be diverse enough to have broad knowledge of the industry. There was no individual staff member that you could identify as not being at the appropriate standard, but almost all of them had exactly the same background, career progression, etc.

2017-11-28