SQL Server Error 1054: Schema-Bound Syntax Fix
In this article
SQL Server error 1054 ("syntax is not allowed in schema-bound") occurs when you try to alter a schema-bound object—such as a view or function created with SCHEMABINDING—using a syntax or operation that is incompatible with that binding. The fix is to drop the schema binding, make your change, then reapply it, or to rewrite the statement so it complies with schema-binding rules. Before you start, you need ALTER permission on the object and, to drop and recreate the binding, ALTER permission on the schema or db_owner rights. You also need a way to run T-SQL, such as SQL Server Management Studio (SSMS) or Azure Data Studio.
What You'll Need
- Access to the database with a login that has ALTER permission on the affected object (and ALTER on the schema to rebind).
- SQL Server Management Studio (SSMS), Azure Data Studio, or another T-SQL client.
- The name of the schema-bound object (view, function, or table with a schema-bound computed column).
- A backup or script of the object definition before you change it.
Step-by-Step
- Identify the schema-bound object. Run this query to find views and functions with schema binding in the current database:
For schema-bound computed columns, check the table definition withSELECT o.name, o.type_desc FROM sys.objects o WHERE o.is_schema_bound = 1 AND o.type IN ('V','IF','TF','FN');sp_helporsys.computed_columnswhereis_schema_bound = 1. - Script the object definition. In Object Explorer, right-click the object, choose Script as > CREATE To > New Query Editor Window. Save the script. This is your rollback if something goes wrong.
- Remove the schema binding. For a view or function, run without the WITH SCHEMABINDING clause, or drop and recreate it. For a computed column, you must drop the column and re-add it without PERSISTED or schema binding—this may require dropping dependent indexes first. Always test on a non-production copy.
- Make your intended change. Now apply the syntax that previously failed—for example, adding a column, changing a data type, or using a
SELECT *in a view. Schema binding forbidsSELECT *, non-deterministic functions, and references to objects in other databases, so adjust the definition accordingly if you plan to rebind. - Reapply schema binding. Recreate the view or function with
WITH SCHEMABINDINGin the header. For computed columns, re-add the column with thePERSISTEDkeyword and schema binding if required. Verify with the query from step 1. - Test dependent objects. Run
sp_refreshvieworsp_refreshsqlmoduleon dependent objects, and execute a few queries that use the view or function to confirm they still work.
Common Mistakes
- Forgetting to script the original definition. Without it, you may not be able to restore the exact binding and permissions.
- Using
SELECT *in a schema-bound view. Schema binding requires explicit column lists;SELECT *is not allowed and will trigger error 1054 or a related error. - Referencing objects in other databases. Schema-bound objects can only reference objects in the same database, and only two-part names are allowed.
- Assuming you can
ALTERa schema-bound computed column. You cannot alter the expression of a schema-bound computed column; you must drop and recreate it, which may require dropping indexes that use it. - Not checking for indexed views. If the view has a clustered index, you must drop the index before altering the view definition, then recreate it after rebinding.
Tips
- Always work in a development or staging database first. Schema binding changes can break dependent objects.
- Use
OBJECT_DEFINITION(OBJECT_ID('schema.object'))to quickly retrieve the current definition. - If you need to keep the object schema-bound but must change its structure, consider creating a new object and swapping names, then rebinding.
- Remember that schema binding prevents changes to underlying tables that would affect the bound object—so plan schema changes together.
- For computed columns, test whether the column truly needs
PERSISTED; removing persistence can avoid schema-binding conflicts.
Troubleshooting
If you still get error 1054 after removing schema binding, check that you removed it from every layer: the view or function header, any computed columns, and any indexed views. Use the query from step 1 to confirm no schema-bound objects remain that reference the object you are altering. If the error mentions a specific syntax element, review the schema-binding restrictions: no SELECT *, no UNION with certain options, no references to other databases, no non-deterministic functions, and no ORDER BY unless a TOP is also present. If you cannot drop the object because of dependencies, use sp_depends or sys.sql_expression_dependencies to find dependent objects and script them before making changes. If the object is an indexed view, drop the index first. If you are unsure, restore a backup to a test server and experiment there. Finally, if the error occurs during deployment, check that your migration script does not include schema-binding-incompatible syntax in a batch that also tries to rebind—separate the steps into distinct batches with GO.
Frequently Asked Questions
What does error 1054 mean exactly?
It means you attempted a statement or syntax that is not permitted on an object that has schema binding enabled. Schema binding restricts changes that could affect the object's dependencies.
Can I disable schema binding without dropping the object?
For views and functions, you can use ALTER VIEW or ALTER FUNCTION and omit the WITH SCHEMABINDING clause. For computed columns, you must drop and re-add the column.
Why does SELECT * cause this error in a schema-bound view?
Schema binding requires explicit column references so that the view's output is fixed and dependencies are tracked. SELECT * is not allowed because it could change if the underlying table changes.
Does schema binding affect performance?
Schema binding itself does not directly improve performance, but it is required for indexed views, which can improve performance. It also prevents certain schema changes that could break the object.
Can I alter a schema-bound function?
You can alter a schema-bound function only if you keep the WITH SCHEMABINDING clause and the new definition still meets schema-binding rules. Otherwise, remove the binding first.
What if I don't have permission to drop schema binding?
You need ALTER permission on the object and ALTER on the schema. If you lack these, ask a database administrator to perform the change or grant you the necessary permissions.