Error 1521

Severity Level 18

Message Text

Sort failed because a table in tempdb used for the processing of the query had a bad data page count. Tempdb should not have been damaged.

Explanation

This error can occur when you are running complex queries that use inefficient query plans. Effective use of indexes can improve query performance.

In most cases, you can resolve the error immediately by inspecting and redefining the indexes on the affected tables.

Action

Follow these steps:

  1. Run the UPDATE STATISTICS statement on the table(s) in question. This will update the information about the distribution of key values in the indexes of the specified table(s).
  2. Modify the query so that the optimizer produces a different query plan. Here are examples of how this can be done:
  3. Examine the table structure of the table(s) involved to ensure that normalization is not an issue.

If the problem persists, contact your primary support provider for assistance. Have the table and index structure of the table(s) involved, as well as a copy of the problematic query, available for review.