Sdu-Tools

SDU Tools: SQL Variant Info for T-SQL

SDU Tools: SQL Variant Info for T-SQL

If you aren’t aware of the SQL Server data type called sql_variant, don’t feel bad; you’re not alone. Many people who’ve worked with SQL Server for a very long time haven’t used it.

sql_variant is a very special data type. It’s the data type that you use when you need to store other data but you’re not sure what type you will need to store. Once it is stored though, it has the appropriate data type.

2026-11-14

SDU Tools: Update Statistics on SQL Server Tables

SDU Tools: Update Statistics on SQL Server Tables

Having up to date statistics is critical for SQL Server choosing appropriate query plans. Poor statistics can lead to poor query plan outcomes.

Generally, SQL Server manages this well by itself. As a rough rule, most versions auto-update statistics when the number of changes is about twenty percent of a count of the number of rows in the table. (Some recent changes have slightly altered how this works but the ball park is pretty good).

2026-11-10

SDU Tools: Version 28 is now released for download

SDU Tools: Version 28 is now released for download

Version 28 of our free SDU Tools for developers and DBAs is now released and winging their way out to our SDU Insiders.

You can find details on the tools here .

If you haven’t been using SDU Tools yet, I’d suggest downloading them and taking a look. At the very least, it can help when you’re trying to work out how to code something in T-SQL.

This is a huge release of the tools.

2026-10-13

SDU Tools: Seconds to Duration in T-SQL

SDU Tools: Seconds to Duration in T-SQL

There are a few places in T-SQL where instead of a time value, you need to work with a duration.

An example is if I want to sleep for a short period. In T-SQL, we can do that with the WAITFOR statement, used like this:

This command would cause SQL Server to wait for 10 minutes. One of the challenges though, is how do I create this duration string in a programmatic way? For example, how do I create the string ‘00:02:00’ if I’m starting with a value of 120 seconds?

2026-10-11

SDU Tools: Determining Leap Years in T-SQL with IsLeapYear

SDU Tools: Determining Leap Years in T-SQL with IsLeapYear

Was 2018 a leap year?

What about the year 2000?

Will 2100 be a leap year?

When I was a young student at school, we learned that leap years were every four years. Then as I got older, I learned that there was more to it than that.

It’s important to understand that any calendar is just an approximation, and there is a lot more to calendars than most people realize.

2026-09-09

SDU Tools: List User Heap Tables in SQL Server

SDU Tools: List User Heap Tables in SQL Server

It’s common advice that most SQL Server tables should have a clustered index. There are some exceptions to this but it’s a pretty general rule, and if in doubt, you should follow it. (Note that this is not the same as having a primary key).

I regularly come across tables without clustered indexes for all the wrong reasons. So, in our free SDU Tools for developers and DBAs, we added a tool that can look for user tables that don’t have a clustered index. No surprise, it’s called ListUserHeapTables because a table without a clustered index is a heap.

2026-04-08

SDU Tools: Nepali Date Processing in SQL Server T-SQL

SDU Tools: Nepali Date Processing 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. Version 27 adds the first set of views and functions for working with Nepali dates. These are useful in Nepal and in a number of Buddhist-related areas.

The first tool added is a view called NepaliMonths. It returns the Nepali names for months. You can see it in the main image above.

2026-04-06

SDU Tools: Token Set Similarity in SQL Server T-SQL

SDU Tools: Token Set 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 TokenSetSimilarity function calculates token set similarity for two strings.

It answers the question: Do these two strings contain mostly the same words, even if the order, spacing, or repetition differs?

It is useful where word order varies, or extra or missing words are common. It can also help where character-level typos are less important than the presence of words.

2026-04-04

SDU Tools: Normalize for Search in SQL Server T-SQL

SDU Tools: Normalize for Search 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 NormalizeForSearch function normalizes a string to make it ready for search operations.

It makes strings comparable by stripping away differences that are usually meaningless for search or matching.

It helps to answer the question: If two strings refer to the same thing, what differences should I ignore before I even start comparing?

2026-04-02

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