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
Blog
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
Removing Git History
Here's a step-by-step guide to removing all Git commit history while retaining the current state of your files. This will also remove all branches and tags. For these instructions, I use Visual Studio Code, but this can be done all from Git Bash. Because my GitHub is public and often traversed, I want to remove … Continue reading Removing Git History
Second Highest Salary
Welcome to exploring a classic SQL interview challenge: "How many different ways can you write an SQL statement that fetches the second-highest salary?" Apparently, I don't even know how to code this puzzle, which Anonymous kindly pointed out in the comments. So now I have to redo this blog post. One point of the puzzle is … Continue reading Second Highest Salary
Advanced SQL Quiz
Hello everyone. Step right up and take the SQL Quiz challenge! Click the above link to take the challenge; read below to review my notes and ramblings. First, I’ve written hundreds of advanced SQL quiz questions that you can use in your learning adventure. This collection is a great asset for identifying gaps in your … Continue reading Advanced SQL Quiz
ChatGPT: SQL as a Religion
Hey, everyone. Thank you for checking out my blog. I can't find an option in WordPress to auto-approve comments, but please add a comment, and I will approve it. I also have a really cool GitHub here of all sorts of puzzles and database writings. I have noticed that ChatGPT is quite adept at refining my … Continue reading ChatGPT: SQL as a Religion
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
