How to Change the Schema of a Schemabound SQL Server Function
Question details
The user needs to modify or transfer the schema of a scalar-valued function in SQL Server that is currently protected by schema binding.

- Product
- SQL Server
- Device & OS
- not provided
- Scenario
- Attempting to transfer a database object to a new schema using the ALTER SCHEMA command.
- Observed behavior
- The schema change command fails and returns an error because SQL Server does not permit direct transfers of objects created with the WITH SCHEMABINDING option.
Before altering any database schema, ensure you have scripted out the exact definition of the affected schemabound function and verified its dependencies.
Remove Schemabinding and Recreate the Function
To move a schemabound function to a new schema, you must temporarily remove the schemabinding, transfer the object, and then reapply the binding.
SQL Server enforces strict dependency checks on objects created with SCHEMABINDING. You cannot use the standard ALTER SCHEMA TRANSFER command directly on these objects. The safest approach is to alter the function to remove the binding before the transfer.
In SQL Server Management Studio (SSMS), locate the scalar-valued function, right-click it, select 'Script Function as', and choose 'ALTER To' in a New Query Editor Window.
In the generated script, locate the 'WITH SCHEMABINDING' clause and delete or comment it out. Execute the script to update the function.
Open a new query window and execute the transfer command: ALTER SCHEMA [NewSchema] TRANSFER [OldSchema].[YourFunctionName];
Update your ALTER script to reflect the [NewSchema] name, add the 'WITH SCHEMABINDING' clause back into the definition, and execute the script to restore dependency protection.

Consult Microsoft Q&A for Complex Dependencies
If your database relies on complex, nested schemabound objects, consult SQL Server specialists to determine the least disruptive deployment strategy.
Document Your Database Schemas Seamlessly with WPS Office
While you manage complex SQL Server dependencies, WPS Office provides a lightweight, highly compatible suite to document your queries, create schema transfer plans, and collaborate on database administration tasks.
- 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
- 2. Create database documentation: Open WPS Writer and start a new document to keep track of your schema changes, SQL scripts, and deployment plans.
- 3. Save and share: Save your documentation in standard .docx format to easily share it with other database administrators or team members.

Frequently Asked Questions
What is the purpose of SCHEMABINDING in SQL Server?
SCHEMABINDING binds a function or view to the schema of the underlying base tables. It prevents those base tables from being altered or dropped in a way that would break the function, ensuring database integrity.
Why does ALTER SCHEMA fail on schemabound objects?
SQL Server prevents moving a schemabound object to a different schema because doing so could silently break the strict dependencies locked in by the SCHEMABINDING declaration. The binding must be explicitly removed before any structural move occurs.
How do I find all schemabound functions in my database?
You can query the sys.sql_modules catalog view in SQL Server by filtering for is_schema_bound = 1. Joining this with sys.objects will list all functions, procedures, and views that utilize schema binding.




