How to fix Error 2720 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 2720 – Schema Binding on System Objects

Why This Error Happens

This error occurs when you attempt to create a schema-bound object (such as a view or function with WITH SCHEMABINDING) that references a system object, catalog view, or system function. SQL Server 2025 explicitly disallows schema binding against system objects because Microsoft reserves the right to modify these objects between updates and service packs without notice, which would break the binding contract. This typically happens when developers mistakenly reference objects like sys.objects, sys.tables, or other system views/functions inside a schema-bound view or function definition.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Object Reference

  • Open the exact error message and note the object name in the second placeholder (the system object being referenced).
  • Run sp_helptext 'YourViewOrFunctionName' in SQL Server Management Studio (SSMS) to review the full definition.
  • Look specifically for references to system catalog views (sys.*), INFORMATION_SCHEMA views, or built-in system functions.

Step 2: Remove the Schema Binding Requirement (If Not Essential)

  • If schema binding isn’t strictly required for your use case, edit the CREATE VIEW or CREATE FUNCTION statement and remove the WITH SCHEMABINDING clause.
  • Re-run the script in SSMS or via sqlcmd -S YourServerName -i script.sql on Windows Server 2025.
  • Confirm the object compiles successfully without errors.

Step 3: Replace System Object References with User Tables or Views

  • If schema binding is required, create a user-defined wrapper view that copies the needed data from the system object into a standard table.
  • Modify your schema-bound object to reference this new user-defined wrapper instead of the system object directly.
  • Use ALTER VIEW or ALTER FUNCTION with WITH SCHEMABINDING once the reference has been redirected.

Step 4: Validate Permissions and Object Context

  • Ensure the login/user executing the script has ALTER and REFERENCES permissions on the underlying objects.
  • Check that you are not accidentally running the script against the master, msdb, or model system databases instead of your intended user database.
  • Use SELECT DB_NAME(); in your query window to confirm the current database context before re-running the script.

Step 5: Rebuild and Test the Schema-Bound Object

  • Drop and recreate the object cleanly using DROP VIEW IF EXISTS YourViewName; followed by the corrected CREATE VIEW ... WITH SCHEMABINDING statement.
  • Run sp_refreshview 'YourViewName' to ensure metadata is updated correctly.
  • Check the SQL Server Error Log (via SSMS or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) to confirm no residual errors are logged.

Alternative or Verification Steps

  • Verify the fix by querying sys.sql_expression_dependencies to confirm the schema-bound object no longer lists any system object as a referenced entity.
  • If schema binding against system data is unavoidable, consider using a scheduled ETL job or indexed staging table that mirrors the system data, allowing schema binding against a fully user-controlled object instead.