The SQL Server DBA questions worth preparing, what each one tests, short model answers, and three answers that current Microsoft documentation corrects.
SQL DBA interview questions come down to one thing: can you keep a production SQL Server recoverable and responsive? They come in three layers. Fundamentals check that your mental model is accurate. Operations (recovery models, backups, high availability, security) check that you can protect data. Troubleshooting scenarios ("the log is full", "users are blocked") check the order in which you act. The 14 questions below follow those layers, each with what it tests and a short model answer, then a worked scenario and a one-week plan. Questions 2, 3 and 13 are marked because current Microsoft documentation contradicts or supersedes a familiar answer; for 2 and 3 it is the answer the earlier version of this page gave. The technical facts here come from Microsoft's SQL Server documentation, linked under Sources.
Fundamentals
1. Clustered vs nonclustered index?
Tests: whether you know how rows are stored, not just found.
Model answer: A clustered index sorts and stores the table's rows by its key, so a table can have only one; a table without one is a heap. A nonclustered index is a separate structure whose entries point back to the row. In a clustered table that pointer (the row locator) is the clustered key; in a heap it points to the row. A primary key builds a clustered index by default unless one already exists. Follow-up to have ready: since every nonclustered index carries the clustered key, a wide clustered key makes all of them bigger.
2. DELETE vs TRUNCATE? (answer corrected)
Tests: logging, locking and limits.
The earlier version of this page called TRUNCATE "not easily rolled back". Microsoft's documentation says a TRUNCATE TABLE operation can be rolled back within a transaction.
Model answer: DELETE removes rows one at a time, logs each one, and accepts a WHERE clause. TRUNCATE deallocates the data pages and logs only the deallocations, so it uses less log space and locks the table and pages rather than each row. It resets identity to the seed, fires no triggers and needs ALTER permission. It is blocked on tables referenced by a foreign key, in an indexed view, published for transactional or merge replication, or system-versioned.
BEGIN TRANSACTION;
TRUNCATE TABLE dbo.StagingOrders;
ROLLBACK TRANSACTION; -- the rows are back3. Temporary table or table variable? (answer corrected)
Tests: whether you understand cardinality estimates.
The earlier version of this page called table variables "in-memory". Microsoft says a table variable is not a memory-only structure: both are created in tempdb, and both are processed in memory while memory allows.
Model answer: The real difference is statistics. Table variables have none, and the optimizer often plans as if they hold no rows, so Microsoft advises caution above roughly 100 rows. Temp tables support full indexing and statistics, which helps joins and index choices. Table variables are scoped to their batch or procedure, can cause fewer recompilations, and ignore transaction rollbacks. Compatibility level 150 added table variable deferred compilation, which improves their estimates.
Operations
4. Explain the three recovery models.
Tests: linking a database setting to how much data the business can lose.
Model answer: Simple reclaims log space automatically and allows no log backups, so you restore only to the end of a backup; log shipping, availability groups and point-in-time restore are unavailable. Full requires log backups, allows point-in-time restore, and the log grows until backed up. Bulk-logged minimally logs most bulk operations; it recovers to the end of any backup but not to a point in time.
5. Design backups for a 15-minute RPO and a one-hour RTO.
Tests: working backwards from targets (RPO: acceptable data loss; RTO: acceptable recovery time).
Model answer: The RPO means full recovery with log backups at least every 15 minutes, since that interval bounds the loss. The RTO limits the restore chain: restoring a full backup plus every log since is often slower than restoring the full, the latest differential and the logs after it, so differentials can help keep recovery inside the hour. Then restore to a test server on a schedule and time it. If a restore can never meet one hour, that argues for an availability group, not a better schedule.
6. What is a tail-log backup?
Tests: whether you would lose the last minutes in a real restore.
Model answer: It captures log records not yet backed up, so you recover to the point of failure with the chain intact. Take one before restoring over an online database, WITH NORECOVERY so nothing changes afterwards. On a damaged database try WITH CONTINUE_AFTER_ERROR; it works only if the log files are intact. Full and bulk-logged recovery only.
7. Synchronous or asynchronous commit in an availability group?
Tests: the latency versus data-loss trade-off.
Model answer: Synchronous commit waits for the secondary to harden the log before confirming, adding latency but guaranteeing a synchronized secondary has every committed transaction. Automatic failover needs synchronous commit on both replicas, a synchronized secondary and cluster quorum. Asynchronous commit doesn't wait, suits a distant disaster-recovery site, and allows only forced failover, which loses transactions not yet sent.
8. TDE or Always Encrypted? And which login type?
Tests: knowing what each control protects against.
Model answer: TDE encrypts data and log files at rest, and backups; tempdb is encrypted once any database uses it. It doesn't cover data in transit, and pages are decrypted in memory, so anyone allowed to query sees normal data. Back up the certificate and private key at once, or the database can't be restored elsewhere. Always Encrypted encrypts chosen columns in the client driver; keys never reach the engine, so DBAs and operators who don't hold the keys can't read the values. Deterministic encryption allows equality lookups and joins but can leak patterns; randomized is stronger but, without secure enclaves, not searchable. For logins, Microsoft calls Windows Authentication much more secure than SQL Server logins (Kerberos or NTLM, password policy, lockout), and advises keeping the well-known sa account disabled unless required.
Troubleshooting
9. The transaction log is full. What do you do? See the worked example below.
10. The application is hanging. How do you find the cause?
Tests: finding the head blocker before killing anything.
Model answer: Query sys.dm_exec_requests for non-zero blocking_session_id and follow the chain to the session that blocks others but isn't blocked. A common culprit has status sleeping with an open transaction: the application ran a statement, never committed, and holds locks while idle. You can kill it, but the fix belongs in the application.
SELECT session_id, blocking_session_id, wait_type, wait_time
FROM sys.dm_exec_requests
WHERE blocking_session_id <> 0;11. How do you investigate and reduce deadlocks?
Tests: knowing blocking and deadlocks differ.
Model answer: Blocking ends when the blocker finishes; a deadlock is a cycle that never would. The lock monitor (checking every 5 seconds by default) rolls back a victim, the transaction cheapest to roll back unless DEADLOCK_PRIORITY says otherwise, and returns error 1205. The default system_health session already captures xml_deadlock_report graphs. To reduce deadlocks: access objects in the same order, keep transactions short, consider READ_COMMITTED_SNAPSHOT, and have the application retry on 1205.
12. A two-second query now takes two minutes. Where do you start?
Tests: telling a plan regression from a data or hardware change.
Model answer: Open Query Store's Regressed Queries view and check whether the query has a new plan. If so, force the previous plan as a stopgap, then find why the optimizer changed its mind: updated statistics, new data volumes, a dropped index. From SQL Server 2017, Automatic Plan Correction can force the last good plan itself.
13. When do you rebuild or reorganize indexes? (answer corrected)
Tests: whether your habits are current.
Avoid answering with a fixed fragmentation cut-off. Microsoft now says maintenance decisions shouldn't rest on fixed fragmentation or page density thresholds alone.
Model answer: Measure first. A rebuild of a rowstore index also updates its statistics with a full scan (except for partitioned or resumable rebuilds), and Microsoft notes that this is often the real reason performance improves, so try a statistics update first at a fraction of the cost. If fragmentation does hurt a specific query, prefer REORGANIZE, which uses fewer resources and is always online, and confirm the gain with a before-and-after comparison in Query Store.
14. DBCC CHECKDB reports corruption. What now?
Tests: protecting data before acting.
Model answer: Restore from the last known good backup, which Microsoft calls the primary recovery method. REPAIR_ALLOW_DATA_LOSS is a last resort and can lose more data than a restore; copy the database files before any repair. Routinely, run CHECKDB WITH PHYSICAL_ONLY often on production and a full CHECKDB periodically.
Worked example: "The log is full"
The weak answer: "I'd shrink the log" or "I'd switch to simple recovery." Microsoft is explicit that shrinking alone can't fix a full log, because only space already freed can be shrunk. Switching to simple may free space, but the database then supports neither log backups nor point-in-time restore, which a database with an RPO usually can't accept.
The strong answer:
- Name the symptom. Error 9002. An online database stays readable but rejects updates.
- Ask the database why. log_reuse_wait_desc in sys.databases names what is preventing log truncation.
SELECT name, recovery_model_desc, log_reuse_wait_desc
FROM sys.databases
WHERE name = N'Sales';- Act on the reason.
- LOG_BACKUP: back up the log. If it has never been backed up, Microsoft notes two log backups are needed before it truncates.
- ACTIVE_TRANSACTION: find the oldest open transaction with DBCC OPENTRAN and agree with its owner to commit or kill it.
- AVAILABILITY_REPLICA: a secondary hasn't hardened the log; check availability group health.
- REPLICATION: check the Log Reader Agent.
- Buy time only if the disk is full. Free space, move the log file to a disk with room, or add a temporary second log file on another disk, which Microsoft treats as temporary, not a design.
- Prevent a repeat. Fix the backup schedule and alert well before the log fills.
You don't need every log_reuse_wait_desc value memorised. The answer has to show that you diagnose before acting and know which fixes cost the business its recovery options.
One-week plan
- Day 1: Questions 1 to 3. Run the TRUNCATE rollback example on a test instance.
- Day 2: Questions 4 to 6. Write a backup plan for stated RPO and RTO targets, then restore to a point in time.
- Day 3: Questions 7 and 8. Sketch a two-site availability group and explain each replica's commit mode.
- Day 4: Questions 10 and 11. Cause a block on purpose in two query windows, find it with the DMV query, then find a deadlock graph in system_health.
- Day 5: Questions 12 and 13 in Query Store.
- Day 6: Say the log-full answer aloud in under three minutes.
- Day 7: Prepare two incident stories (an outage you helped fix, a change that went wrong) in STAR form; our STAR interview questions guide covers the format.
If the role includes query writing, see our SQL interview questions for 3 years of experience and SQL query questions for 5 years of experience.
Those incident stories can also go into the Knowledge Base of Verve AI's Interview Copilot, which accepts STAR-format entries and draws on the documents you enable when it suggests answers in a live interview.
Sources
- TRUNCATE can be rolled back in a transaction; page deallocation logging; locks; identity reset; restrictions; no triggers; ALTER permission: https://learn.microsoft.com/en-us/sql/t-sql/statements/truncate-table-transact-sql
- Table variables not memory-only, created in tempdb; no distribution statistics; the 100-row caution; scope; rollback; deferred compilation at compatibility level 150; temp tables' full index support and statistics: https://learn.microsoft.com/en-us/sql/t-sql/data-types/table-transact-sql
- Clustered vs nonclustered indexes, heaps, row locator, primary key creates clustered index by default: https://learn.microsoft.com/en-us/sql/relational-databases/indexes/clustered-and-nonclustered-indexes-described
- Recovery models, log backups, point-in-time restore, features unavailable under simple recovery, RPO and RTO per model: https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/recovery-models-sql-server
- Full, differential and log backup definitions: https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/backup-overview-sql-server
- Tail-log backups, NORECOVERY, CONTINUE_AFTER_ERROR: https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/tail-log-backups-sql-server
- Synchronous and asynchronous commit, automatic failover requirements, forced failover data loss: https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/availability-modes-always-on-availability-groups
- TDE scope, backups, tempdb, no encryption in transit, certificate backup: https://learn.microsoft.com/en-us/sql/relational-databases/security/encryption/transparent-data-encryption
- Always Encrypted, keys never exposed to the engine, deterministic vs randomized: https://learn.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine
- Authentication modes, Windows Authentication much more secure, sa account advice: https://learn.microsoft.com/en-us/sql/relational-databases/security/choose-an-authentication-mode
- Error 9002, log_reuse_wait_desc, shrinking alone cannot fix a full log, two log backups if never backed up, DBCC OPENTRAN, AVAILABILITY_REPLICA, temporary extra log file: https://learn.microsoft.com/en-us/sql/relational-databases/logs/troubleshoot-a-full-transaction-log-sql-server-error-9002
- Blocking, head blocker, blocking_session_id, sleeping session with open transaction: https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/performance/understand-resolve-blocking
- Deadlock detection interval, victim choice, DEADLOCK_PRIORITY, error 1205, system_health and xml_deadlock_report, ways to reduce deadlocks: https://learn.microsoft.com/en-us/sql/relational-databases/sql-server-deadlocks-guide
- Query Store regressed queries, plan forcing, Automatic Plan Correction from SQL Server 2017, A/B testing: https://learn.microsoft.com/en-us/sql/relational-databases/performance/query-store-usage-scenarios
- No fixed fragmentation thresholds; rebuild updates statistics; reorganize preferred and always online; maintenance strategy: https://learn.microsoft.com/en-us/sql/relational-databases/indexes/reorganize-and-rebuild-indexes
- Restore from backup as primary method, REPAIR_ALLOW_DATA_LOSS as last resort, PHYSICAL_ONLY guidance: https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkdb-transact-sql
- Knowledge Base accepts STAR-format entries; copilot uses enabled documents: https://docs.vervecopilot.com/features/knowledge-base
Ryan
CEO of Verve AI








