Views, functions, stored procedures, triggers, CTEs and recursive CTEs, window functions, temp tables and table variables, MERGE, JSON functions and full-text search in T-SQL.
-
What is an indexed view in SQL Server, and when is it worth the write cost?
Junior
Theory
SQL Features
-
What is the difference between change tracking and change data capture in SQL Server, and when would you use each?
Mid-Level
Theory
SQL Features
-
How would you remove duplicate rows from a SQL Server table while keeping the newest row for each key?
Intermediate
Sql
SQL Features
-
How do you prevent cycles when users can move nodes in a hierarchy stored as an adjacency list?
Mid-Level
Sql
SQL Features
-
What is the gaps-and-islands problem, and how do you solve it with window functions?
Mid-Level
Sql
SQL Features
-
What are key-range locks in SQL Server, and when do they appear?
Senior
Theory
SQL Features
-
How would you keep Azure AI Search in sync with a SQL Server database?
Intermediate
Theory
SQL Features
-
Why is NOLOCK dangerous in SQL Server, and what should you use instead?
Mid-Level
Theory
SQL Features
-
What is the difference between a view, a function and a stored procedure in SQL Server, and when would you use each? Explain scalar, inline table-valued and multi-statement table-valued functions, and why the difference between the last two matters for performance.
Views, scalar functions, inline and multi-statement table-valued functions and stored procedures in SQL Server: what each is, when to use it, and the performance differences.
Junior
Theory
SQL Features
Β· π 2 follow-ups
-
Should a .NET team use stored procedures or keep SQL in the application with EF Core or Dapper? Give the real pros and cons, show how you call a procedure from .NET, and explain how you handle permissions, versioning and deployment (for example DACPAC or migrations).
Stored procedures versus EF Core and Dapper in a .NET codebase: performance myths, security and permissions, calling procedures from .NET, versioning and deploying them with DACPACs or migrations.
Mid-Level
Theory
SQL Features
Β· π 2 follow-ups Β· π 1 real-world
-
What are triggers in SQL Server? Explain AFTER versus INSTEAD OF triggers, the inserted and deleted pseudo-tables, why a trigger must be set-based, the hidden side effects triggers cause, and the alternatives you would consider, such as temporal tables, an outbox table or change data capture.
SQL Server DML triggers: AFTER and INSTEAD OF, inserted and deleted, writing them set-based, their hidden costs, and alternatives such as temporal tables, the outbox pattern, change tracking and CDC.
Mid-Level
Theory
SQL Features
Β· π 2 follow-ups Β· π 1 real-world
-
What is a common table expression (CTE) in T-SQL? Show when it improves a query, explain why SQL Server does not materialise a CTE and what that means if you reference it twice, and compare CTEs with derived tables (subqueries) and temp tables.
Non-recursive CTEs in SQL Server: syntax and readability, inlining rather than materialisation, the cost of referencing a CTE more than once, and choosing between CTEs, derived tables and temp tables.
Intermediate
Sql
SQL Features
Β· π 3 follow-ups
-
How do you query a hierarchy such as an org chart or a product category tree in SQL Server? Write a recursive CTE, explain the anchor and recursive members, MAXRECURSION, how you detect and stop cycles, and when you would use hierarchyid or a closure table instead.
Recursive CTEs for hierarchies in SQL Server: anchor and recursive members, depth and path tracking, MAXRECURSION, cycle detection, indexing, and alternatives such as hierarchyid and closure tables.
Mid-Level
Sql
SQL Features
Β· π 2 follow-ups Β· π 1 real-world
-
What are window functions in SQL Server? Use ROW_NUMBER, RANK, DENSE_RANK, LAG/LEAD and SUM() OVER to solve top-N per group, deduplication and running totals, and explain PARTITION BY, ORDER BY and the frame clause (ROWS vs RANGE) and how to index for them.
SQL Server window functions: ranking functions, LAG and LEAD, aggregate windows with frames, top-N per group, deduplication and running totals, ROWS versus RANGE, and the POC indexing pattern.
Mid-Level
Sql
SQL Features
Β· π 2 follow-ups Β· π 1 real-world
-
When would you use a temp table, a table variable or a CTE in SQL Server? Explain how they differ in statistics, recompilation, scope, transactions and tempdb usage, and what table variable deferred compilation changed in SQL Server 2019.
Temp tables versus table variables versus CTEs in SQL Server: statistics and cardinality estimates, recompiles, scope, transaction behaviour, tempdb usage, deferred compilation and memory-optimised table variables.
Mid-Level
Theory
SQL Features
Β· π 2 follow-ups Β· π 1 real-world
-
Your team uses MERGE for upserts in SQL Server. What are its known problems, why can concurrent MERGE statements still violate a primary key, what does HOLDLOCK change, and what safer upsert patterns would you use instead?
The T-SQL MERGE statement: syntax, its history of bugs, the race condition under concurrency, HOLDLOCK and serializable range locks, duplicate source rows, and safer upsert patterns.
Senior
Theory
SQL Features
Β· π 2 follow-ups Β· π 1 real-world
-
How do you work with JSON in SQL Server? Show OPENJSON, JSON_VALUE, JSON_QUERY, JSON_MODIFY and FOR JSON, explain how you index a JSON property, what the native json data type adds, and how you decide whether to store JSON at all instead of normal columns.
JSON in SQL Server and Azure SQL: parsing with OPENJSON and JSON_VALUE, producing JSON with FOR JSON, indexing JSON properties, the native json type and JSON index, and when JSON storage is the right design.
Mid-Level
Sql
SQL Features
Β· π 2 follow-ups Β· π 1 real-world
-
Users want to search product descriptions by keyword, and LIKE '%term%' is slow and gives poor results. What is SQL Server full-text search, how do CONTAINS and FREETEXT work, what are its limits, and when would you use Azure AI Search or Elasticsearch instead?
Full-text search in SQL Server and Azure SQL: why LIKE with a leading wildcard fails, full-text catalogs and indexes, word breakers and stemming, CONTAINS, FREETEXT and ranking functions, and when to move to Azure AI Search or Elasticsearch.
Intermediate
Theory
SQL Features
Β· π 2 follow-ups
-
Code review: a colleague's stored procedure loops over orders with a cursor, builds a dynamic SQL filter by concatenating a parameter, uses SELECT * with NOLOCK on every table, and has no SET XACT_ABORT ON or error handling around its transaction. What would you flag, in what order, and how would you rewrite it?
Reviewing a T-SQL stored procedure: SQL injection through concatenated dynamic SQL, transaction handling without XACT_ABORT, NOLOCK data errors, row-by-row cursors, SELECT * and how to rewrite it set-based and safely.
Senior
CodeReview
SQL Features
Β· π 2 follow-ups Β· π 1 real-world