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

Troubleshooting Guide: Error 12803 – Containment Cannot Be Enabled for System Database

Why This Error Happens

Error 12803 occurs because SQL Server 2025 does not permit database containment to be enabled on system databases such as master, model, msdb, or tempdb. The CONTAINMENT property is a database-scoped setting designed exclusively for user databases, allowing them to be more portable and isolated from instance-level metadata. When an administrator or an automated deployment script attempts to run ALTER DATABASE with a CONTAINMENT clause against a system database, the SQL Server Engine rejects the operation at the parser/validation layer, throwing this error as a hard-coded restriction rather than a configurable permission issue.

Step-by-Step Resolution Guide

Step 1: Identify the Target Database in Your Script

  • Open the T-SQL script or deployment job that triggered the error.
  • Locate the ALTER DATABASE [DatabaseName] SET CONTAINMENT = PARTIAL (or FULL) statement.
  • Confirm whether [DatabaseName] resolves to master, model, msdb, or tempdb.
  • If using a variable or parameter (e.g., @DBName), print its runtime value using PRINT @DBName; to verify it isn’t accidentally pointing to a system database.

Step 2: Correct the Script to Target a User Database

  • Replace the system database reference with the intended user database name.
  • Example corrected syntax:
  ALTER DATABASE [YourUserDB]
  SET CONTAINMENT = PARTIAL;
  • If the intent was to create a new contained database, use CREATE DATABASE with containment specified at creation time instead of altering an existing system database:
  CREATE DATABASE [YourUserDB] CONTAINMENT = PARTIAL;

Step 3: Validate Instance-Level Containment Settings

  • If containment is required broadly, ensure the contained database authentication server configuration is enabled first:
  EXEC sp_configure 'contained database authentication', 1;
  RECONFIGURE;
  • This setting does not affect system databases but is a prerequisite for any user database to support containment.

Step 4: Re-run the Deployment or Migration Script

  • Execute the corrected script against the proper user database.
  • Check SQL Server Error Logs via SQL Server Management Studio (SSMS) > Management > SQL Server Logs or the path C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG on Windows Server 2025 to confirm no further containment-related errors appear.

Alternative or Verification Steps

  • Verify the fix by querying the containment status of the target database: SELECT name, containment, containment_desc FROM sys.databases WHERE name = 'YourUserDB'; — the containment_desc column should return PARTIAL (not NONE).
  • If the script is part of a third-party tool or automated DACPAC/BACPAC deployment, inspect the deployment contributor or publish profile (.publish.xml) to ensure it isn’t incorrectly flagging system databases for containment during provisioning.