How to Find Nth Highest Salary in SQL Server

How to Find Nth Highest Salary in SQL Server

A payroll analyst at a mid-size staffing company once sent me a screenshot of a report. It showed the “third highest salary” in a department, and the number was wrong. Two people shared the top salary, and the query counted them as separate ranks. The report fed a compensation review, so a small logic bug … Read more

How to Find Second Highest Salary in SQL Server

How to Find Second Highest Salary in SQL Server

A payroll analyst at a mid-sized staffing company once sent me a spreadsheet and a worried email. Their HR dashboard showed the “second highest salary” per department, but two departments returned the same number as the top salary. The query had used TOP 1 with a sort, and it counted tied employees as separate ranks. … Read more

Scalar Function vs Table Valued Function SQL Server

Scalar Function vs Table Valued Function SQL Server

A retail client once called me because their order report had gone from 8 seconds to 14 minutes. Nothing had changed except one thing. A developer had wrapped a tax calculation in a user-defined function and called it for every row in a 3-million-row table. The query looked clean, but it ran one function call … Read more

How To Check If SQL Server Is Reachable

How To Check If SQL Server Is Reachable

A retail company called me on a Monday morning because its order app had stopped working. The error message said “A network-related or instance-specific error occurred,” and the team had already restarted the app servers twice. Nobody had checked whether the app servers could even reach the database. It turned out someone had changed a … Read more

How to Save Stored Procedure in SQL Server

How To Save Stored Procedure In SQL Server

When I trained a new database developer on my team last year, one of the first questions he asked me was, “How do I actually save this stored procedure once I’ve written it?” It’s a fair question, because unlike saving a Word document or an Excel file, saving a stored procedure in SQL Server doesn’t … Read more

Stored Procedure vs View

Stored Procedure vs View

When I first started managing databases for a company in Dallas, my team lead asked me to “just create a view instead of a procedure” for a reporting request. I remember pausing, because at that point I genuinely wasn’t sure why it mattered. Years later, after building and maintaining dozens of production databases, I can … Read more

SQL Server Reporting Services

SQL Server Reporting Services

I’ve lost count of how many times a client in Denver or Atlanta has handed me a pile of spreadsheets and asked, “Can you turn this into something our executives can actually look at every Monday morning?” That’s the exact problem SQL Server Reporting Services was designed to solve. If you’re trying to understand what … Read more

What Do SQL Server Integration Services Do?

What Do SQL Server Integration Services Do?

I still remember the first time a client in Chicago handed me a mess of spreadsheets, a legacy Oracle database, and a SQL Server instance, and asked me to “just make the data talk to each other.” That’s the exact problem SQL Server Integration Services was built to solve. If you’ve ever asked yourself what … Read more

SQL Server FLOOR

sql server floor

In this article, I will take you through the SQL Server FLOOR function from an architectural and development perspective: its formal mathematical definition, underlying data type preservation rules, negative number behaviors, performance implications, and practical schema design patterns. SQL Server FLOOR What is the SQL Server FLOOR Function? The FLOOR function in Microsoft SQL Server … Read more