Sql-Server

SDU Tools: Levenshtein Distance in SQL Server T-SQL

SDU Tools: Levenshtein Distance in SQL Server T-SQL

Our free SDU Tools for developers and DBAs, now includes a very large number of tools, with procedures, functions, and views. The LevenshteinDistance function calculates the Levenshtein distance between two strings.

It essentially answers the question How far apart are these two strings in terms of character edits?, where edits are inserting, deleting, or substituting a character. In this calculation, each edit has a cost of 1.

Empty and NULL values on input return NULL.

2026-03-31

SDU Tools: Jaro Winkler Similarity in SQL Server T-SQL

SDU Tools: Jaro Winkler Similarity in SQL Server T-SQL

Our free SDU Tools for developers and DBAs, now includes a very large number of tools, with procedures, functions, and views. The JaroWinklerSimilarity function that we have added calculates the Jaro Winkler similarity for two strings.

It essentially answers the question Do these two short strings probably refer to the same thing, even if they aren’t exactly the same?.

It can be used where typos are common, or characters are transposed, and where prefixes matter more than suffixes. Empty and NULL values on input return NULL.

2026-03-29

SDU Tools: Formatting Bytes in SQL Server T-SQL

SDU Tools: Formatting Bytes in SQL Server T-SQL

Our free SDU Tools for developers and DBAs, now includes a very large number of tools, with procedures, functions, and views. The FormatBytes function can now be used to take a number of bytes, and to format it as a string, with appropriate units.

The calculation can be done using SI units (where 1000 bytes is one kB, or binary units where 1024 bytes is one KB. It can also output IEC based units like the kibibyte.

2026-03-27

SSRS and Fabric Paginated Reports: Be very careful with using "c" formatting for currency

SSRS and Fabric Paginated Reports: Be very careful with using "c" formatting for currency

While on site this week, another common problem that I see everywhere arose again.

When you need to format currency, you use the “c” format right? It’s in nearly every set of course materials I’ve ever seen. And people do it in almost every demonstration.

But so often, that’s wrong!

When you do this, you’re telling the system to display the monetary value using the local currency.

Is that correct though?

2026-03-21

Opinion: Are certification exams useful for experienced people?

Opinion: Are certification exams useful for experienced people?

Over the years, I’ve seen so many discussions regarding the certification process and exams. I’ve seen posts from many people that are very experienced with products saying they can’t see any point in the certification exams and also argue that competencies in the Microsoft Partner program shouldn’t be based on exams. They feel these people should somehow just be recognised for their other contributions.

Grandfathering

Regarding the certification process, I don’t agree that anyone should be just grandfathered in. Any of the people that have a great deal of knowledge and experience really should be able to just take the exams and be done with it.

2026-03-17

Opinion: Sticking with a plan even if you don't like it

Opinion: Sticking with a plan even if you don't like it

Something I really struggle with in this industry is when newcomers to a system want to change standards within existing systems because they think something else is better. It’s a sign of immaturity yet it often applies to people who should be senior. Many system architects fall into this category.

What’s in a PK name?

For example, a vendor system that I’ve been working with has single column primary keys in all tables, and all the primary key columns are named PKey_ID (I’ve changed it a bit to protect the guilty). Now I can’t say I like that naming at all, but that’s not the point. There are a large number of tables that already have that naming scheme.

2026-03-15

SQL: What's that 1033 thing and what are locale IDs?

SQL: What's that 1033 thing and what are locale IDs?

When writing and working with T-SQL in SQL Server, you’ll often come across the number 1033. In many cases, that will have the word English associated with it. But what are these numbers, and which ones does SQL Server know about?

The number 1033 comes from the reference to a Windows Locale ID. You’ll find the list of Windows Locale IDs here:

Microsoft Locale ID List

It’s a big list with entries that look like this:

2026-03-13

SQL: Linked Servers - It's a matter of being compatible

SQL: Linked Servers - It's a matter of being compatible

The on-premises versions of SQL Server have the ability to connect one server to another via a mechanism called Linked Servers.

Azure-based SQL Server databases can communicate with each other by a mechanism called External Tables. I’ll write more about External Tables again soon.

Common performance issue with linked servers

With Linked Servers, I often hear people describing performance problems. There’s a configuration setting that commonly causes this, yet it seems to be almost unknown.

2026-03-11

SQL: Linked Servers: Don't hard code server names

SQL: Linked Servers: Don't hard code server names

I’m not a great fan of linked servers in SQL Server but they are often necessary. If I’m working with the latest version of SQL Server, I really prefer to use External Data Sources and External Tables. But not everyone is on the latest version. In the meantime, what I see all the time, is people hardcoding server names like this:

SDUPROD2022.WWIDB.Payroll.Employees

That makes your code really hard to manage. One option to get around that is to use synonyms.

2026-03-09

SQL: Computed Columns: It's a matter of persistence

SQL: Computed Columns: It's a matter of persistence

Most SQL Server developers are aware that they can create computed columns. We do that by defining a column AS some expression like this:

CREATE TABLE Sales.OrderLines
(
    ...
    UnitPrice decimal(18, 2) NOT NULL,
    PickedQuantity decimal(18, 3) NOT NULL,
    LineTotal AS ROUND(UnitPrice * PickedQuantity, 2)
    ...
)

Each time the value from that LineTotal column is queried, the calculation is performed so the result can be returned. This makes sense when the value is changing regularly and the value is queried infrequently.

2026-03-07