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

Troubleshooting Guide: SQL Server Error 11730 – Database Name Cannot Be Specified for Sequence Object in Default Constraints

Why This Error Happens

This error occurs when a DEFAULT constraint references a sequence object (via NEXT VALUE FOR) using a three-part or four-part name that includes the database name (e.g., MyDatabase.dbo.MySequence). SQL Server 2025 enforces a restriction that sequence objects used in default constraints must be referenced only by schema-qualified names within the same database context, not cross-database references. This is a parser-level validation rule tied to how default constraints bind to objects at compile time, and it cannot be bypassed by permissions or configuration changes alone.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Default Constraint

  • Open SQL Server Management Studio (SSMS) connected to your Windows Server 2025 / Windows 11 instance.
  • Run the following query to locate constraints using NEXT VALUE FOR:
SELECT OBJECT_NAME(parent_object_id) AS TableName, definition
FROM sys.default_constraints
WHERE definition LIKE '%NEXT VALUE FOR%';
  • Note the exact table and column where the faulty constraint is defined.

Step 2: Rewrite the Constraint Without the Database Name

  • Drop the existing default constraint using:
ALTER TABLE dbo.YourTable DROP CONSTRAINT DF_YourConstraintName;
  • Recreate it using only schema and object name (no database prefix):
ALTER TABLE dbo.YourTable 
ADD CONSTRAINT DF_YourConstraintName 
DEFAULT (NEXT VALUE FOR dbo.YourSequenceName) FOR YourColumn;
  • Ensure the sequence object exists in the same database as the table.

Step 3: Migrate Cross-Database Sequences Locally

  • If the sequence genuinely resides in another database, create a local copy of the sequence object in the target database:
CREATE SEQUENCE dbo.YourSequenceName
AS INT
START WITH 1
INCREMENT BY 1;
  • Update application logic or synonyms if cross-database access was intentional, using a SYNONYM instead of a direct reference in the default constraint.

Step 4: Validate Schema and Script Consistency

  • Re-run deployment or migration scripts (DACPAC, SSDT projects) to confirm no other objects reference sequences with a database-qualified name.
  • Check Extended Events or the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for recurrence of Error 11730 during deployment.

Alternative or Verification Steps

  • Verify the fix by executing an INSERT statement into the affected table and confirming the sequence-generated value populates correctly without error.
  • If the error persists in automated deployment pipelines, inspect your DACPAC or Entity Framework migration scripts for hardcoded three-part names and regenerate them using schema-only qualified references.