Design Pattern // Safe Type Conversion with T-SQL — Catch Errors Instead of Aborting the ETL Process

A single value that won’t convert — a 25.5 in an integer column, an empty string, a date like 20240230 — and the ETL run aborts mid-import. Anyone who loads text data from upstream systems knows it: the delivery doesn’t honour the agreed interface, and a bare CONVERT throws an exception instead of cleanly logging the offending value. This article describes … Read more

Data Quality // Type Conversion Basics with T-SQL — CAST, CONVERT, TRY_CAST and TRY_CONVERT Compared

A date from a CSV file lands as text in the database — and suddenly the 2nd of November turns into the 11th of February. These silent misinterpretations are the classic pitfall of type conversion in SQL Server. Anyone who knows CAST, CONVERT, TRY_CAST and TRY_CONVERT together with the style parameter avoids them. The essentials up front: Prerequisite: SQL Server with SSMS; … Read more

Porting T-SQL to PL/pgSQL — Migrating Procedures and Functions

The data is over, the schema stands — and then there are 200 stored procedures sitting there that no tool translates for you. pgloader migrates tables and data, but the logic in procedures, functions, and triggers stays behind. This is the phase that’s actually work: porting T-SQL to PL/pgSQL, line by line, with understanding instead of search-and-replace. The … Read more

Design Pattern // Logging an ETL Process with T-SQL — How to Capture Run, Component and Action in Evaluable Log Tables

An ETL process finishes without an exception — but was everything really loaded that should have been? The mere fact that a process did not abort says nothing about whether it actually did what was expected of it. A readable, evaluable log is what turns a gut feeling into a defensible statement. This design pattern … Read more

SSIS vs. SQL — When to Use SSIS, When Pure T-SQL, When to Combine?

SSIS, T-SQL, or a combination of both? There is no single right answer. What there is, is a handful of decision criteria against which every concrete choice — technology and extent of use — should be measured: readability, source code management, impersonation. This article series takes these three axes and delivers a concrete argument per axis. Anyone arguing ETL … Read more

Commenting Complex SQL Statements — Parallel Inline Documentation That Keeps Code Readable

Anyone who writes a 200-line SELECT with a recursive CTE understands it completely while writing it — and three weeks later, not a word of it. Inline comments are the safety net against that. The problem: placed badly, they destroy the very readability they are meant to preserve. What this article covers: Prerequisite: The examples run against AdventureWorksDW2017 (table [dbo].[DimEmployee], a … Read more

Formatting SQL Statements (Part 2) — Statement Structure: SELECT, WHERE, FROM, JOIN

If you can’t tell at a glance where the WHERE clause of a 200-line SELECT statement starts and ends, you have a structure problem — not a content problem. This article shows the layout that keeps long statements navigable. → Part of a series. This is part 2 and covers statement structure (SELECT, WHERE, FROM, JOIN). The basics for identifiers, delimiters, commas, and aliases are … Read more

Editor Options in SSMS — Make SQL Code Look the Same on Every Team Machine

A SQL statement that looks neatly indented on one developer’s machine collapses into a staircase on a colleague’s — even though nobody touched the code. The culprit is almost always a difference in editor settings: a different tab width, tabs instead of spaces, a non-monospaced font. Readable SQL code in a team doesn’t start with … Read more