SQL Server error 1053 occurs when you run DROP STATISTICS without specifying both the table and the statistics name. The fix is to use the full syntax: DROP STATISTICS schema.table_name.statistics_name; or, for a statistics object created on a table, DROP STATISTICS table_name.statistics_name;. You must provide both the table name and the statistics name in a single statement—you cannot drop statistics by name alone. This guide walks you through the correct syntax, common pitfalls, and troubleshooting steps.
What You'll Need
- Access to SQL Server Management Studio (SSMS) or another client that can run T-SQL.
- Sufficient permissions: you need ALTER permission on the table or membership in the db_owner or sysadmin role.
- The exact names of the table and the statistics you want to drop. You can find these using
sys.statsorsp_helpstats. - Knowledge of the schema name if the table is not in the default schema (usually dbo).
Step-by-Step
- Identify the statistics you want to drop. Run a query against
sys.statsto list all statistics for the table. For example:
Alternatively, useSELECT s.name AS stats_name, OBJECT_NAME(s.object_id) AS table_name FROM sys.stats s WHERE OBJECT_NAME(s.object_id) = 'YourTableName';sp_helpstats 'YourTableName';to see statistics names. Note the exact statistics name and the table name. - Construct the DROP STATISTICS statement correctly. The syntax requires both the table and the statistics name, separated by a dot. If the table is in a non-default schema, include the schema name. For example:
If the statistics were created on a view, use the view name instead of the table name. The key is that you must provide both identifiers.DROP STATISTICS dbo.YourTableName.YourStatsName; - Run the statement in SSMS or your query tool. Open a new query window, paste the corrected statement, and execute it. You should see a message like "Command(s) completed successfully." If you still get error 1053, double-check that you have not omitted either the table name or the statistics name.
- Verify the statistics are gone. Re-run the query from step 1 or use
sp_helpstatsagain to confirm the statistics no longer appear. You can also checksys.statsdirectly. - If you need to drop multiple statistics, repeat the process for each one. You cannot drop multiple statistics in a single DROP STATISTICS statement; each statement targets one statistics object. You can script multiple statements or use a cursor, but each must include both the table and statistics name.
Common Mistakes
- Omitting the table name. Writing
DROP STATISTICS YourStatsName;will trigger error 1053 because SQL Server cannot determine which table the statistics belong to. Always include the table name. - Using the wrong schema. If the table is not in the default schema (e.g., not dbo), you must include the schema name:
DROP STATISTICS schema_name.table_name.stats_name;. Otherwise, SQL Server may not find the table. - Confusing statistics with indexes. Statistics created automatically by the query optimizer have names like
_WA_Sys_.... You can drop them, but be aware that they may be recreated automatically if the optimizer needs them. UseDROP STATISTICSonly for user-created statistics or when you have a specific reason. - Incorrect quoting. If your table or statistics names contain spaces or special characters, use brackets or double quotes:
DROP STATISTICS [dbo].[My Table].[My Stats];. Without proper delimiters, you may get syntax errors or error 1053. - Attempting to drop statistics on a table variable or temporary table. Statistics on table variables are not supported in the same way; error 1053 may appear if you try to drop statistics that do not exist or are not user-defined.
Tips
- Always script out the DROP STATISTICS statement from SSMS Object Explorer to avoid syntax mistakes. Right-click the statistics in the Object Explorer, choose Script Statistics as, then DROP To.
- Use
IF EXISTSto avoid errors if the statistics do not exist:DROP STATISTICS IF EXISTS dbo.TableName.StatsName;(available in SQL Server 2016 and later). - Before dropping statistics, consider whether they are still needed. Dropping user-created statistics can affect query performance. Test in a non-production environment first.
- If you are cleaning up auto-created statistics, you can use
DROP STATISTICSwith the full name, but note that the optimizer may recreate them. To prevent recreation, you can disable auto-create statistics on the database, but this is generally not recommended. - Keep a record of the statistics you drop, especially in production, so you can recreate them if needed. You can script the CREATE STATISTICS statement before dropping.
Troubleshooting
If you still encounter error 1053 after following the steps, check the following:
- Verify the exact names. Use
SELECT name FROM sys.stats WHERE object_id = OBJECT_ID('YourTableName');to get the precise statistics name. Names are case-sensitive depending on the database collation. - Check permissions. Ensure your login has ALTER permission on the table. You can test with
SELECT HAS_PERMS_BY_NAME('YourTableName', 'OBJECT', 'ALTER');which should return 1. - Confirm the object type. Statistics can be created on tables or indexed views. If you are trying to drop statistics on a view, use the view name in the DROP STATISTICS statement. Error 1053 may occur if you reference a table that does not have the statistics.
- Look for hidden characters. If you copied the statement from another source, there may be non-printing characters. Retype the statement manually or use a clean editor.
- Check for dependent objects. In rare cases, statistics may be referenced by a schema-bound object, preventing drop. You would see a different error, but it's worth checking.
- Use the correct database context. Ensure you are in the database that contains the table. You can specify the database in the statement:
USE YourDatabase; DROP STATISTICS dbo.TableName.StatsName;.
If none of these resolve the issue, try running the statement with the full three-part name: DROP STATISTICS DatabaseName.SchemaName.TableName.StatsName; (though this is not standard syntax; the standard is two-part for table and statistics). Actually, the correct syntax is DROP STATISTICS table_or_indexed_view_name.statistics_name with optional schema. So use DROP STATISTICS schema_name.table_name.statistics_name.
Frequently Asked Questions
Why do I get error 1053 when I try to drop statistics?
Error 1053 means you did not provide both the table name and the statistics name in the DROP STATISTICS statement. SQL Server requires both to uniquely identify the statistics object.
Can I drop statistics without specifying the table name?
No. The DROP STATISTICS syntax requires the table (or indexed view) name and the statistics name. You cannot drop statistics by name alone.
What is the correct syntax to drop statistics?
Use DROP STATISTICS schema_name.table_name.statistics_name; or DROP STATISTICS table_name.statistics_name; if the table is in the default schema. Include the schema if needed.
How do I find the statistics name for a table?
Query sys.stats filtering by object_id, or run sp_helpstats 'TableName';. The results show the statistics names.
Can I drop multiple statistics in one statement?
No, DROP STATISTICS only drops one statistics object per statement. You must run separate statements for each statistics you want to drop.
Will dropping statistics affect query performance?
It can. User-created statistics help the query optimizer generate efficient plans. Drop them only if you are sure they are not needed, and consider testing in a non-production environment first.