If you’re learning SQL or looking for a real-world dataset to sharpen your database skills, the Netflix sample database could be an option. This free, open-source database is based on publicly available information from Netflix’s Engagement Report and Global Top 10 weekly lists, making it both relevant and engaging for practice purposes.
DBMS
Database Management Systems
Dynamic PIVOT in SQL Server for Unknown Column Values
Most pivot operations in SQL tend to use hardcoded column lists. This is where you explicitly specify every column name in the IN clause. That works great when you know exactly which values will appear in your data. But what happens when those values change? When new categories get added, when you’re working with user-generated data, or when you’re building a query that needs to work across different datasets?
That’s when you might want to consider dynamic PIVOT. Instead of hardcoding column names, you query the data to discover what columns you need, build the PIVOT query as a string, and execute it dynamically. It’s more complex than static PIVOT, but it’s pretty much essential when your column values aren’t predetermined.
Calculating Days Between a Fixed Date and Dynamic Dates with DATEDIFF()
Sometimes you need to measure how many days have passed between a specific reference point and a constantly moving target. SQL Server’s DATEDIFF() function handles this elegantly by letting you combine hardcoded dates with dynamic functions like GETDATE(). This can be useful for calculating things like age, days since an event, or time remaining until a deadline.
The main point here is that DATEDIFF() doesn’t care whether its date arguments are literals, functions, or even subqueries. It just needs two date values to compare. When you use GETDATE() or similar functions, you’re telling SQL Server to calculate the difference based on the current moment, which means the result changes every time you run the query.
Restoring SQL Server Backups in Docker on macOS with VS Code
Whether you are a long-time Mac user or recently transitioned from Windows, running SQL Server on macOS brings a unique set of challenges. Most tutorials assume you’re on Windows using SQL Server Management Studio (SSMS), which is a tool that doesn’t exist for Mac. Instead, you’re likely running SQL Server inside a Docker container and using a tool like VS Code.
Monitoring Query Store Storage Usage in SQL Server (T-SQL)
When you have Query Store enabled in SQL Server, it consumes disk space in order to store query text, execution plans, and runtime statistics. Monitoring storage usage can help you avoid situations where Query Store fills up and stops capturing data or switches to read-only mode.
How to View Query Execution History Over Time in SQL Server
In SQL Server, Query Store aggregates performance statistics into time intervals, allowing you to see how query performance changes over time. This historical view helps you identify when performance degraded, spot patterns like daily or hourly spikes, and correlate performance changes with deployments or data changes.
This assumes that Query Store is enabled on the database in question. So assuming Query Store is enabled on the database, you can use the following queries to check the execution history of queries over time.
What is a Missing Index in SQL Server?
SQL Server has a concept of “missing indexes”. And no, it’s not referring to an index that used to be there but has now disappeared. Rather, the missing index concept is designed to help us improve the performance of our database.
A missing index is an index that doesn’t yet exist on your table but probably should. SQL Server actually tracks queries that would benefit from indexes and stores suggestions in a set of dynamic management views (DMVs) called the missing index DMVs.
When you run a query and the optimizer thinks that this would be way faster with an index on those columns, it logs that suggestion. Over time, these suggestions accumulate, giving you a prioritized list of indexes that could improve your database’s performance.
How to Install SQL Server on a Mac in 2026
Running a full-featured Microsoft SQL Server on a Mac used to be a headache, but as of 2026, it is smoother than ever. Thanks to improvements in Docker Desktop and macOS’s Rosetta 2 translation, you can now run the enterprise-grade engine (including the new SQL Server 2025 Preview) directly on your M1, M2, M3, or M4 Mac.
This guide will walk you through setting up a modern SQL Server environment from scratch.
How to View All Queries in Query Store in SQL Server
SQL Server’s Query Store captures all executed queries (or a subset based on your capture mode) along with their execution statistics. Viewing the complete list of captured queries helps you understand what’s been tracked and provides a starting point for performance analysis.
Using DATEDIFF() with LEAD() to Calculate Time Until Future Events
When you’re analyzing how events unfold over time in a SQL database, one of the biggest challenges can be efficiently comparing what’s happening now to what comes next. Each event typically appears as its own row with a timestamp, but meaningful insight often comes from understanding how those timestamps relate to one another. Fortunately SQL Server provides some useful tools for this kind of sequential analysis.
Rather than relying on bulky self-joins or multi-step logic, SQL window functions offer a streamlined way to track these transitions. For example, by pairing the LEAD() function with DATEDIFF(), you can instantly measure the gap between consecutive events and surface insights that would otherwise require far more complex queries.