nerdexam
Microsoft

70-465 · Question #42

You need to recommend a solution to improve the performance of usp.UpdateInventory. The solution must minimize the amount of development effort. What should you include in the recommendation?

The correct answer is A. A table variable. When optimizing stored procedures that perform iterative or batch updates, replacing cursors or inefficient row-by-row operations with table variables can significantly improve performance with minimal code changes.

Submitted by marco_it· Mar 5, 2026Design and implement database solutions for SQL Server

Question

You need to recommend a solution to improve the performance of usp.UpdateInventory. The solution must minimize the amount of development effort. What should you include in the recommendation?

Options

  • AA table variable
  • BA common table expression
  • CA subquery
  • DA cursor

How the community answered

(67 responses)
  • A
    84% (56)
  • B
    3% (2)
  • C
    4% (3)
  • D
    9% (6)

Why each option

When optimizing stored procedures that perform iterative or batch updates, replacing cursors or inefficient row-by-row operations with table variables can significantly improve performance with minimal code changes.

AA table variableCorrect

A table variable stores intermediate result sets in memory (tempdb), allowing set-based operations that replace slow row-by-row processing. Table variables have less locking overhead than temporary tables, require no explicit cleanup, and can be used to batch updates in usp.UpdateInventory with minimal refactoring, satisfying the requirement to minimize development effort.

BA common table expression

A common table expression (CTE) is a named temporary result set scoped to a single statement and does not persist data between operations, making it unsuitable as a standalone performance improvement for a stored procedure performing inventory updates.

CA subquery

A subquery is evaluated inline within a single query and does not provide a mechanism to store or reuse intermediate result sets across multiple statements within the stored procedure, offering limited performance benefit for complex update logic.

DA cursor

A cursor processes rows one at a time (row-by-row), which is typically the cause of poor performance in stored procedures rather than a solution to it; replacing existing logic with a cursor would likely worsen performance.

Concept tested: Optimizing stored procedures using table variables

Source: https://learn.microsoft.com/en-us/sql/t-sql/data-types/table-transact-sql?view=sql-server-ver16

Topics

#performance optimization#table variables#stored procedures#T-SQL

Community Discussion

No community discussion yet for this question.

Full 70-465 Practice