📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

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.

Phase 12 — SQL Server

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.

  1. 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
  2. How would you remove duplicate rows from a SQL Server table while keeping the newest row for each key?
    Intermediate Sql SQL Features
  3. How do you prevent cycles when users can move nodes in a hierarchy stored as an adjacency list?
    Mid-Level Sql SQL Features
  4. What is the gaps-and-islands problem, and how do you solve it with window functions?
    Mid-Level Sql SQL Features
  5. What are key-range locks in SQL Server, and when do they appear?
    Senior Theory SQL Features
  6. How would you keep Azure AI Search in sync with a SQL Server database?
    Intermediate Theory SQL Features
  7. Why is NOLOCK dangerous in SQL Server, and what should you use instead?
    Mid-Level Theory SQL Features
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. What are the SQL Server isolation levels? Explain read uncommitted, read committed, repeatable read and serializable, the anomalies each one prevents (dirty reads, non-repeatable reads, phantoms, lost updates), how each is implemented with locks, and how you choose one.

    The four locking isolation levels in SQL Server, the read anomalies each prevents, how S, X and key-range locks implement them, where snapshot-based levels fit, and how to choose and set the level from T-SQL and .NET.

    Mid-Level Theory Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  20. What is the blocked process report in SQL Server, how do you set it up on SQL Server and Azure SQL Database, and how do you read one?

    Capturing historical blocking with the blocked process threshold and the blocked_process_report Extended Events event, and reading the blocked and blocking process sections.

    Mid-Level Theory Transactions and Locking

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me