1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.
SQL Server and Azure SQL for .NET engineers: database design and normalisation, indexing, execution plans and query tuning, T-SQL features, and transactions, locking and isolation levels.
Covers how .NET strings become nvarchar parameters, why an nvarchar parameter against a varchar column converts the column and blocks seeks (collation nuances), finding it in plans and the plan cache, and fixing it with IsUnicode(false)/HasColumnType, DbString/AnsiString and typed SqlParameters.
Covers the per-index write, log, memory and blocking cost, building an index set from real query patterns, finding unused indexes with sys.dm_db_index_usage_stats and missing indexes with the missing-index DMVs and Query Store, their caveats (resets, no column-order or write-cost awareness), safe removal by disabling first, and Azure SQL automatic tuning.
What an optimiser timeout in a SQL Server plan really means (a capped search, not a wall-clock failure), when it matters, and how to make the query easier to optimise.
Why the cost percentages in SQL Server plans are always estimates, the cases where they lie badly (bad cardinality, scalar UDFs, remote calls, parallelism), and how to find the real hotspot.
Why new rows beyond the last histogram step get badly under-estimated in SQL Server, how the legacy and new cardinality estimators differ, and how to keep statistics current after loads.
How SQL Server 2022's Parameter Sensitive Plan (PSP) optimisation builds a dispatcher plan with query variants, and the parameter-sniffing cases it leaves unsolved.
Why a Query Store forced plan can silently stop being used, how to detect forcing failures, and how to manage forced plans over time.
Diagnosing memory grant starvation (RESOURCE_SEMAPHORE waits) when CPU is low, and fixing it at the query, server and Resource Governor level.
Covers the SQL Server query processing pipeline: parse, bind/algebrise, trivial plan and cost-based optimisation phases, plan caching and reuse, and execution, with what the optimiser's estimates depend on.
Covers reading SQL Server execution plans: estimated vs actual plans, right-to-left data flow, seek, scan, key lookup, nested loops, hash match, merge join, sort, warnings, and estimated vs actual rows as the first check.
Covers SQL Server statistics objects (header, density vector, 200-step histogram), auto-create and auto-update thresholds, sampling, CE versions tied to compatibility level, ascending-key and correlated-predicate problems, and how stale statistics show up in plans.
Covers diagnosing parameter sniffing: why SSMS and the app get different plans (ARITHABORT and other SET options, local variables), finding the regressed plan in Query Store, comparing compiled and runtime parameter values, and fixes from OPTION (RECOMPILE) and OPTIMIZE FOR to plan forcing, Query Store hints, PSP optimisation and code changes.
Covers the SQL Server plan cache: cache keys (text hash, SET options, database), object types (Adhoc, Prepared, Proc), simple and forced parameterisation, single-use plan bloat from concatenated SQL and variable parameter lengths, sp_executesql, optimize for ad hoc workloads and how to measure cache health.
Covers Query Store: captured query text, plans, runtime and wait statistics per interval, built-in reports, finding regressions, plan forcing and its failure modes, Query Store hints, key settings (capture mode, size, interval, cleanup, READ_ONLY flip) and Azure SQL defaults including automatic plan correction.
Covers SQL Server missing index suggestions in plans and the sys.dm_db_missing_index_* DMVs: how they are generated, what impact means, their limitations (column order, overlap, no write cost, include bloat, reset on restart), and a workload-based process for turning them into real indexes.
Covers a hands-on T-SQL tuning walkthrough: baseline with SET STATISTICS IO, TIME and the actual plan, reading the plan for scans, residual predicates, key lookups and sorts, fixing SARGability and indexing, rewriting the query, and proving the improvement with logical reads and Query Store.
Covers a production incident on Azure SQL: confirming CPU saturation with sys.dm_db_resource_stats, finding the culprit with sys.dm_exec_requests and Query Store, telling a plan regression from a new or changed query, mitigating with plan forcing, rollback or scaling, fixing the root cause, and preventing it with release gates and alerts.
Covers query memory grants: which operators need memory, how grants are sized from estimates and row width, spills to tempdb and their warnings, oversized grants and RESOURCE_SEMAPHORE waits, memory grant feedback (batch, row mode, percentile and persistence), and diagnosis with DMVs, Query Store and hints.
Covers a methodical approach to environment-specific slowness: comparing actual plans, data volume and distribution, statistics, parameter values, compatibility level and configuration, blocking and resource limits between dev and production, and fixing the real cause rather than the symptom.