Interview Questions That Actually Reveal SQL Skill

Good SQL Server interview questions reveal how someone reasons when the answer is not obvious. Give the candidate a small problem, then listen to the questions asked before the query appears.

Two plain ceramic mugs beside an open blank notebook and pencil on a quiet wooden table.

Ask What the Result Should Mean

Start with a task that has more than one reasonable interpretation. Ask for each customer’s latest order. Then wait to hear whether ties, customers without orders, and time zones need clarification.

A candidate who asks about the business rule is not avoiding SQL. Those details determine whether the answer is correct. Memorizing ROW_NUMBER does not settle what latest means.

WITH Orders AS
(
    SELECT * FROM (VALUES
      (1, 101, CONVERT(date, '20260101', 112)),
      (1, 102, CONVERT(date, '20260101', 112)),
      (2, 103, CONVERT(date, '20260102', 112))
    ) AS v(CustomerId, OrderId, OrderDate)
)
SELECT CustomerId, OrderId, OrderDate,
       ROW_NUMBER() OVER
       (PARTITION BY CustomerId ORDER BY OrderDate DESC, OrderId DESC) AS rn
FROM Orders;

Ask the candidate to explain the tie-breaker rather than merely filter rn to one. Would the business accept the greater identifier as the winner? A confident answer should still acknowledge that assumption.

Make Missing Data Part of the Problem

NULL questions are useful when they test a real reporting mistake. Ask why a count differs from the number of rows. Then ask how a missing amount should affect the result.

WITH Amounts AS
(
    SELECT Amount FROM (VALUES (10), (NULL), (20)) AS v(Amount)
)
SELECT COUNT(*) AS row_count, COUNT(Amount) AS known_amount_count,
       SUM(Amount) AS known_amount_total
FROM Amounts;

The candidate should distinguish missing information from a known zero. Replacing every NULL with zero is a business choice, not automatic cleanup. Ask for an example where that replacement would mislead a reader.

Follow with a LEFT JOIN question if the role involves reporting. A filter on the optional table can change which rows survive. Let the candidate draw the intermediate rows on paper.

Offer a Slow Query Without Offering a Diagnosis

Say that an application search became slow this morning. Do not tell the candidate that an index is missing. Ask what evidence would be collected before making a change.

SELECT session_id, status, command, wait_type,
       blocking_session_id, cpu_time, total_elapsed_time
FROM sys.dm_exec_requests
WHERE session_id <> @@SPID;

Strong answers separate blocking, resource pressure, plan changes, and changed inputs. They ask whether every request is affected and what changed recently. They also recognize that one snapshot can miss the problem.

Do not require a memorized DMV column list unless that is genuinely the job. Let candidates consult documentation after explaining the approach. You are hiring judgment, not an offline autocomplete feature.

Ask How a Change Reaches Production

Give the candidate a proposed index and ask what happens next. Useful answers discuss write overhead, storage, representative tests, and a reversal plan. The best response depends on the workload and available maintenance window.

For a DBA role, ask how a successful backup becomes a demonstrated recovery capability. Look for a restore to another location, integrity checks, and application validation. A green backup job alone does not answer the recovery question.

SELECT TOP (10) database_name, type,
       backup_start_date, backup_finish_date, is_copy_only
FROM msdb.dbo.backupset
ORDER BY backup_finish_date DESC;

Ask what this history proves and what it cannot prove. It records backup operations known to this instance. It does not establish that the media remains available or that the application can use a restored database.

Score the Reasoning Consistently

Use the same core scenario for candidates applying to the same role. Record whether requirements were clarified, assumptions were stated, and proposed checks could distinguish likely causes. That is more useful than a vague impression of confidence.

Separate syntax fluency from problem-solving depth in your notes. A small syntax mistake can be corrected quickly. An unexamined decision to kill sessions or change production settings deserves a different discussion.

Leave space for the candidate to revise an answer after receiving new evidence. Real troubleshooting includes changing your mind. Reward a clear correction instead of treating the first guess as a permanent verdict.

Listen to the Questions Coming Back

Candidates should ask about workload size, availability expectations, access, and the team’s change process. Those questions show how the role will be approached. They also help both sides decide whether expectations are realistic.

End with a short explanation of an unfamiliar result rather than another trivia round. Ask the candidate to describe the next safe experiment. You learn more from that conversation than from the maximum length of a type nobody uses.

A technical interview is not a memory contest, it is a sample of working judgment.

This post was rewritten from scratch in September 2026. The original, published on 2011-11-03, was a short announcement about something that no longer exists. The address is the same, the subject is now something worth keeping.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.

Best Practices, Database, SQL Scripts, SQL Server
Previous Post
SQL SERVER – Import CSV into Database – Transferring File Content into a Database Table using CSVexpress
Next Post
How to Read a Stored Procedure You Did Not Write

Related Posts

37 Comments. Leave new

  • Pinal, congratulations and a great achievement. Another book up on the stands from you. It was really fun interviewing you and Pinal. Hope to see many more of these things in future. Best wishes.

    Reply
  • pinal

    I JUST BROUGHT ALL OF YOUR BOOKS AND THIS NEW BOOK OF INTERVIEW QUESTIONS.

    THANK YOU SO MUCH.

    Reply
  • I didn’t even know that while writing an email to you few hours back that you gonna have third book this soon…. Congrates to you both. :)

    Reply
  • Vadivel Mohanakrishnan
    November 3, 2011 8:12 am

    Congratulations to both of you. You guys beat me … i was planning an (e)book on this topic for quite sometime :)

    Reply
  • Thats awesome Pinal!
    I really look forward to get the book…
    Thanks a lot for such awesome release and happy bday to ur blog too… :-)

    Reply
  • Divyang Panchasara
    November 3, 2011 8:34 am

    I m very excited about this book so just now I have placed order on flipkart.

    Reply
  • Congrats once again Pinal. I am excited to see this book title from two SQL Gurus. Wishing all the best to Vinod Kumar on this journey.

    Reply
  • Chirag Satasiya
    November 3, 2011 9:24 am

    Hi Pinal sir,
    Congratulations for this book.

    I am also look very forward for this.
    Thank you so much for your efforts.

    Regard$
    Chirag Satasiya

    Reply
  • just ordered it, thanks pinal….

    Reply
  • Thank you thank you all!

    I truly appreciate your love and passion towards SQL.

    Reply
  • Its helpful for too many….

    Reply
  • Swetha Nagalakshmi
    November 3, 2011 10:01 am

    Hi Sir,

    Congratulations to both of you sir.. and Very Happy Birthday to Vinod Sir.

    Reply
  • Congratulations your new book. Could I have one copy?

    Reply
  • Hi Pinal and vinod,

    Congratulation !!!.

    Thanks for this, i was trying to find something like that. Now i got.

    i am going to place order.

    Reply
  • Nakul Vachhrajani
    November 3, 2011 12:04 pm

    Hello!

    Many congratulations on the publication of your 3rd book! The combination of authors is a killer, and I will be sure to get a copy.

    This year has been great for the SQL Server community as we got not one, but 3 new books from you.

    Have a wonderful day!

    Reply
  • Krishna Prakash. H. N.
    November 3, 2011 12:59 pm

    Good achievement….

    Reply
  • Congratulations Pinal…! Happy Birthday Vinod.

    Reply
  • Geetanjali Agarwal
    November 3, 2011 2:05 pm

    Congratulations to both of you !!!!!!! n Happy Birthday to Vinod !!!!

    My guess was very close to the answer..n I am very happy after seeing the title of the book…that’s awesome… :)

    Many Congratulations…

    Reply
  • Gopalakrishnan Arthanarisamy
    November 3, 2011 3:18 pm

    Hi Pinal & Vinod,

    Thank you for your wonderful contributions on SQL Server Interview Questions. Vinod…Wish you Happy Birthday.

    @ Pinal,
    I have prepared document on all your interview questions (32 Days of Interview Questions) from your blogs.

    Gopalakrishnan Arthanarisamy,
    Bangalore, Unisys.

    Reply
  • Congratulations Pinal and Vinod

    I have ordered the book. Looking forward to read it.

    Ganesh

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.