Using Multiple CTEs in a Single Query

Common Table Expressions (CTEs) are a handy way to break down a complex query into readable, reusable pieces. When you need several intermediate results – say, a filtered set, an aggregation, and a ranking – you can stack multiple CTE definitions together. PostgreSQL, SQL Server, MySQL 8+, and many other engines support this syntax.

Read more

Connect to Azure SQL Database from Your Mac

If you’ve set up an Azure SQL Database, you’ll almost certainly want to connect to it at some point. You’ll probably want to connect to it, and then run a bunch of SQL queries, just like you would do if you had SQL Server installed locally or across the network.

Fortunately, connecting to Azure SQL Database is relatively straight forward. Let’s look at two options for connecting via a Mac: SQL command line tools and VS Code.

Read more

Create an Azure SQL Database for Free

Azure SQL Database is a fully managed cloud database service used by organizations of all sizes, from startups to large enterprises. It provides high availability, scalability, and security out of the box while supporting the familiar SQL Server engine. Because it runs entirely in the cloud, you can build data-driven applications without managing hardware or dealing with routine maintenance.

Even though it’s built mainly for enterprise-grade workloads, Azure SQL can also be a great choice if you’re a developer or student who wants to learn SQL, build prototypes, experiment with cloud-based apps, etc.

And Microsoft offers us a free option, so you can do it all at no cost.

Read more

Getting Started with Azure Sign Up

Azure is Microsoft’s cloud computing platform that offers a wide range of services, including databases, virtual machines, and analytics tools. For SQL developers, Azure provides tools like Azure SQL Database and Azure Data Studio, which make it easy to build and scale applications in the cloud.

Even though Azure is built with enterprise scenarios in mind, Azure SQL provides a flexible platform for SQL developers and students to learn, prototype, and experiment in the cloud.

Below are the steps I used to sign up with Azure. I did this in order to take advantage of the free SQL database offer (which provides free access to a SQL database for life). But for the purpose of this article, we’ll look solely at the sign up process, as you’ll need to do this regardless of whether you’re doing the free SQL database thing.

Read more

How to Run SQL Server on your Mac with Azure SQL (for Free)

If you’re a Mac developer, setting up SQL Server locally is probably starting to feel like more trouble than it’s worth. Between workarounds like Docker, virtual machines, and third-party tools, just getting a working SQL Server environment on macOS is not exactly your run-of-the-mill installation.

Add to that Microsoft’s announcement to retire SQL Edge in September 2025 (SQL Edge was our only hope of installing SQL Server on a Mac without using a virtual machine), not to mention the impending retirement of Azure Data Studio in Feb 2026 (which we could use to connect to SQL Server), and you may start to wonder whether you should drop the whole idea of using SQL Server altogether.

Read more

Connect to Azure SQL Database Using VS Code

Visual Studio Code (VS Code) is an excellent tool for connecting to Azure SQL Database and managing data right from within your development environment. With a few simple steps, you can run queries, explore tables, and integrate database tasks into your development workflow.

This article walks you through connecting to Azure SQL using VS Code.

Read more

Install SQL Server Command Line Tools on a Mac

mssql-tools is a command-line utility developed by Microsoft that provides tools for interacting with Microsoft SQL Server environments. It includes sqlcmd for executing Transact-SQL (T-SQL) queries and scripts, and bcp (Bulk Copy Program) for importing and exporting large volumes of data. These tools can be useful when you want to manage SQL Server directly from the terminal without relying on graphical interfaces.

One cool thing about mssql-tools is that it’s cross-platform. It can be installed on macOS, Linux, and Windows machines. This makes it ideal for modern development environments, especially when working with cloud-based solutions like Azure SQL Database.

In this article, we’ll look at how to install mssql-tools on a Mac and use it to connect securely to an Azure SQL Database.

Read more

Create a Resource Group in the Azure Portal

An Azure resource group is a container that logically organizes related Azure resources, allowing for easier management, deployment, and access control of those resources. When we do things like create a SQL database, we need to create a resource group for the database to belong to. We can create the resource group while creating the database, but we can also create the resource group separately.

This article shows the steps for creating a resource group separately, from the Azure portal home page.

Read more