Blog

Using Babelfish Compass’s ANTLR Grammar to Analyze T-SQL Code Quality

Hello everyone! Problem You're given a T-SQL code base and need to answer questions like: Which T-SQL scripts have index hints? Which scripts use cursors? How about those dreaded GOTO statements? Which scripts use OPTION (RECOMPILE)? Which tables have BIGINT columns? I have something that can help answer these questions. Solution We can use the … Continue reading Using Babelfish Compass’s ANTLR Grammar to Analyze T-SQL Code Quality

T-SQL Tuesday 200: I Bet a Query is Bad When…

Missing Semicolons: My Earliest Warning Sign of a SQL Server Codebase One of the earliest signs that I'm about to have a rough time with a SQL Server codebase is when I notice that semicolons aren't used as statement terminators. And I'm not talking about the occasional missing semicolon; I am talking about not using … Continue reading T-SQL Tuesday 200: I Bet a Query is Bad When…

Classifying Numbers with SQL

This puzzle takes us into Discrete Mathematics and Number Theory, where numbers aren’t just values—they're types. Whether a number is odd, even, prime, or part of a sequence like Fibonacci, Number Theory is all about how we classify them. I started by generating a table of integers and labeling each with its corresponding classification. A … Continue reading Classifying Numbers with SQL

Recursion using Functions and Stored Procedures in SQL Server

When considering recursion in SQL, developers typically think of Common Table Expressions (CTEs) to solve hierarchical models. However, SQL Server also allows for recursive functions and stored procedures, a feature not in Microsoft's documentation or the literature I have encountered. This approach to recursion is less known, and rightly so, as there are usually more … Continue reading Recursion using Functions and Stored Procedures in SQL Server

Attributes, Fields, and Columns

In the context of databases, the terms attribute, field, and column are often used interchangeably, especially in relational databases. However, there are slight nuances in the way they're used within different contexts. Here, I create a blog post to quickly define the differences and nuances of these terms. If you are unfamiliar with ERD, Conceptual, … Continue reading Attributes, Fields, and Columns

Understanding Different Key Types in SQL

In the realm of database design, there are a total of twelve distinct keys to be taken into account. Primary, foreign, and unique keys are typically well-known among SQL developers, as they are implemented through SQL syntax and serve as constraints. However, when undertaking database design, it is important to consider additional key types that … Continue reading Understanding Different Key Types in SQL