// SQL Server error reference

SQL Server error 1913: Index or statistics name already exists

CREATE INDEX or CREATE STATISTICS used a name that already exists on that table or view. Index names are unique per table.

Error number
1913
Severity
16
Category
Constraints and keys
Error message
The operation failed because an index or statistics with name '%.*ls' already exists on %S_MSG '%.*ls'.

What it means

Index and statistics names must be unique within a table or view (unlike constraint names, which are unique per schema). Re-running an index script, or creating an index with the same name as an existing statistics object, raises 1913.

Common causes

  • Running a deployment script that creates an index twice.
  • An index or statistics object with the same name was created earlier, possibly by a tuning tool.

How to fix it

  1. Rebuild the existing index in place with DROP_EXISTING.

    CREATE INDEX IX_Orders_CustomerId ON dbo.Orders (CustomerId)
    INCLUDE (OrderDate)
    WITH (DROP_EXISTING = ON);
  2. Or guard the create.

    IF NOT EXISTS (SELECT 1 FROM sys.indexes
                   WHERE object_id = OBJECT_ID(N'dbo.Orders') AND name = N'IX_Orders_CustomerId')
        CREATE INDEX IX_Orders_CustomerId ON dbo.Orders (CustomerId);
  3. Check statistics names too.

    SELECT name FROM sys.stats WHERE object_id = OBJECT_ID(N'dbo.Orders');

Related errors

More constraints and keys errors

The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.

// fewer errors, faster fixes

Work on SQL Server in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.