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 Use STRING_AGG() in SQL Server with Custom Separators and Sorting

In SQL Server, STRING_AGG() is an aggregate function that concatenates string values from a group into a single string. It’s a handy tool for doing things like creating comma-separated lists from related data.

In this article we’ll check out how to use STRING_AGG() with different separators. We’ll also see how we can control the order of the concatenated strings.

Read more

4 Ways to Format the Current Date as MM/DD/YYYY in SQL Server

In SQL Server, we can use functions like GETDATE() to get the current date and time. There are also other functions, like CURRENT_TIMESTAMP, SYSDATETIME(), etc. These functions return values using one of the valid date/time types. For example, GETDATE() and CURRENT_TIMESTAMP return a datetime type, while SYSDATETIME() returns a datetime2(7) value.

Either way, if we want the current date to be displayed using MM/DD/YYYY format, we’ll need to do some extra work.

Fortunately SQL Server provides us with a range of options for doing this, and so we can pick the one that suits our scenario.

With that in mind, here are four ways to format the current date as MM/DD/YYYY in SQL Server.

Read more

5 Ways of Checking the Existence of Temporary Tables in SQL Server

When working with temporary tables in SQL Server, one of the most common tasks is checking whether the table already exists before creating it. This prevents errors in the event the table already exists, and ensures your scripts run smoothly regardless of previous executions.

In this article, we’ll explore five different approaches to checking for temporary table existence in SQL Server.

Read more

Convert MMDDYYYY to DATE in SQL Server

Sometimes we get dates in a format that SQL Server has trouble with when we try to convert them to an actual DATE value. One example would be dates in MMDDYYYY format. While it might be easy to assume that SQL Server would be able to handle this easily, when we stop to think about it, this format is fraught with danger.

The MMDDYYYY format is ambiguous. While we might know that the first two digits are for the month, SQL Server doesn’t know this. Some countries/regions use the first two digits for the day (like DDMMYYYY). So if we get a date like, 01032025, how would SQL Server know whether it’s the first day of the third month, or the third day of the first month?

Read more

The Difference Between LIST_SELECT() and LIST_SLICE() in DuckDB

DuckDB has a list_select() function and a list_slice() function, and both do a similar thing. They allow us to extract values from lists based on their index in the list. But they’re quite different in the way they work. One function allows us to select elements based on a range, while the other function allows us to handpick each element we want returned.

Read more

How to Find Users Connected to SQL Server (T-SQL)

Checking which users are connected to a SQL Server can be useful for both performance and security. It helps database admins see who’s using the system, what applications they’re running, and from where. This makes it easier to troubleshoot issues like slow queries or high resource usage. It also helps spot unusual or unauthorized access, such as logins from unknown machines or at odd times. Regularly reviewing active connections is a simple way to keep the server running smoothly and securely.

Below are five queries we can use to check which users are connected to a SQL Server instance.

Read more