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

Troubleshooting Guide: SQL Server Error 1852 — Shrink File Operation Failure

Why This Error Happens

Error 1852 typically occurs when SQL Server cannot shrink a physical database file because a portion of the file is being held by an active process, an open transaction, or a page that cannot be relocated (such as pages belonging to a non-shrinkable allocation unit). This can also happen if the file has insufficient free space to reclaim, or if there is file-system level corruption or a lock held by an external backup/antivirus agent scanning the .mdf/.ldf file. In some cases, DBCC SHRINKFILE fails because replication, Change Data Capture (CDC), or a long-running index rebuild is holding pages that prevent compaction.

Step-by-Step Resolution Guide

Step 1: Review the ERRORLOG and Current Database State

  • Navigate to the SQL Server log directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • Open the most recent ERRORLOG file and search for “1852” to identify the specific file ID and database involved.
  • Run DBCC CHECKDB (YourDatabaseName) WITH NO_INFOREPAIR; to rule out physical corruption as the root cause.

Step 2: Identify and Terminate Blocking Processes

  • Execute SELECT * FROM sys.dm_exec_requests WHERE command LIKE '%SHRINK%'; to check if a shrink operation is already in progress.
  • Run sp_who2 or query sys.dm_tran_locks to identify sessions holding locks on the target database file.
  • If CDC or replication is enabled, temporarily disable it using EXEC sp_cdc_disable_db; or pause the replication job before retrying the shrink.
  • Kill any blocking session using KILL <session_id>; only after confirming it is safe to terminate.

Step 3: Retry the Shrink Operation with Correct Syntax

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run the shrink command manually with explicit file ID: DBCC SHRINKFILE (N'YourLogicalFileName', TRUNCATEONLY);
  • If TRUNCATEONLY fails, attempt a target size shrink: DBCC SHRINKFILE (N'YourLogicalFileName', 100); (adjust size in MB as needed).
  • Monitor progress using SELECT percent_complete FROM sys.dm_exec_requests WHERE command = 'DBCC';

Step 4: Check File System and Storage Permissions

  • Verify that the SQL Server service account has full read/write permissions on the data directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • Confirm that no antivirus or Windows Defender real-time scanning is locking the .mdf/.ldf files; add an exclusion for the SQL Server DATA folder in Windows Security settings.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER if file locks persist after permission changes.

Step 5: Rebuild Indexes Before Retrying Shrink

  • Since shrink operations can be blocked by fragmented or non-contiguous allocation units, rebuild all indexes first using ALTER INDEX ALL ON YourTableName REBUILD;
  • Re-run the shrink command from Step 3 after index maintenance completes.
  • If the issue persists on a specific filegroup, consider moving data to a new filegroup and dropping the old one instead of shrinking.

Alternative or Verification Steps

  • Verify the fix by re-running DBCC SHRINKFILE and confirming the operation completes without Error 1852, then check sys.database_files to confirm the new file size matches expectations.
  • If shrinking still fails, consider an alternative approach: back up the database, create a new file group, migrate tables using CREATE INDEX ... WITH (DROP_EXISTING = ON, ON NewFileGroup), and remove the original oversized file once data migration is verified complete.

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

Troubleshooting Guide: SQL Server Error 1851 – Relative Path Too Long

Why This Error Happens

This error occurs when SQL Server attempts to resolve a relative file path (such as a filename specified without a full directory path during database creation, backup, or restore operations) by prefixing it with the server’s configured default data or log path, and the resulting concatenated string exceeds the Windows maximum path length limitation. This commonly happens when the default data/log directory path set in SQL Server is already very long (deeply nested folders), leaving little room for the actual filename before hitting the 260-character MAX_PATH limit. It can also surface after a migration or restore where database or file names are unusually long, or when the instance’s default path was changed to a deeply nested network or local directory structure.

Step-by-Step Resolution Guide

Step 1: Identify the Current Default Data and Log Path

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Right-click the server in Object Explorer, select Properties, then go to the Database Settings tab.
  • Note the values under Database default locations for both Data and Log — check their full string length.
  • Alternatively, run the following query to check configured defaults:
EXEC xp_instance_regread
  N'HKEY_LOCAL_MACHINE',
  N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',
  N'DefaultData';

Step 2: Shorten the Default Path or Relocate Data Directories

  • If the default path is deeply nested (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\), consider relocating it to a shorter root path such as D:\SQLData\.
  • In SSMS, under Server Properties > Database Settings, update the Data and Log default paths to the shorter directory.
  • Restart the SQL Server service via SQL Server Configuration Manager for the change to take effect.
  • Ensure the new directory has correct NTFS permissions granted to the SQL Server service account (Full Control on the new folder).

Step 3: Specify an Explicit Full Path Instead of a Relative Filename

  • When running CREATE DATABASE, RESTORE DATABASE, or ALTER DATABASE ... MODIFY FILE, always supply the fully qualified path rather than relying on the default path substitution.
  • Example:
RESTORE DATABASE MyDB
FROM DISK = 'D:\Backups\MyDB.bak'
WITH MOVE 'MyDB_Data' TO 'D:\SQLData\MyDB.mdf',
     MOVE 'MyDB_Log' TO 'D:\SQLLogs\MyDB_log.ldf';
  • This bypasses the automatic path-prefixing logic that triggers Error 1851.

Step 4: Enable Long Path Support at the OS Level (Windows Server 2025 / Windows 11)

  • Open Group Policy Editor (gpedit.msc) and navigate to Computer Configuration > Administrative Templates > System > Filesystem.
  • Enable Enable Win32 long paths.
  • Alternatively, set the registry key directly:
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1
  • Reboot the server for the policy to take full effect, then retry the database operation.

Alternative or Verification Steps

  • Verify the fix by re-running the original CREATE DATABASE or RESTORE command that previously failed and confirming no Error 1851 appears in the SQL Server Error Log or Event Viewer (Event ID 1851).
  • As an alternative, use shorter, non-nested database and file names (e.g., avoid excessively descriptive filenames) and store databases on a drive with a shallow directory structure (e.g., D:\DB\ instead of C:\Program Files\Microsoft SQL Server\...\DATA\).

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

Troubleshooting Guide: SQL Server Error 1850 – Database File Valid on More Than One Brick

Why This Error Happens

This error occurs when SQL Server’s distributed/multi-brick storage architecture detects that a database file path resolves to more than one storage brick (node) in a Storage Spaces Direct or distributed filegroup configuration. This typically happens due to duplicate or overlapping file path mappings in the brick metadata, often caused by a misconfigured storage pool, a stale cluster metadata cache, or manual file copy operations that duplicated file identifiers across bricks. It can also surface after a failed brick rebalancing operation left orphaned references pointing to the same logical file name on two separate physical bricks.

Step-by-Step Resolution Guide

Step 1: Verify Brick Topology and File Ownership

  • Run SELECT * FROM sys.dm_db_brick_files; to list which bricks currently claim ownership of the file in question.
  • Confirm whether the file name ‘%.*ls’ appears under more than one brick_id in the result set.
  • Cross-check this against the physical storage layout using Get-StoragePool and Get-PhysicalDisk in PowerShell on Windows Server 2025.

Step 2: Clear Stale Cluster and Brick Metadata Cache

  • Stop the SQL Server service: Stop-Service MSSQLSERVER.
  • Clear the distributed metadata cache by running Clear-ClusterNode -CacheOnly (Windows Server 2025 clustering cmdlet) on each node hosting a brick.
  • Restart the Cluster Service: Restart-Service ClusSvc.
  • Restart SQL Server and re-attempt the attach operation using RESTORE DATABASE ... WITH NORECOVERY or CREATE DATABASE ... FOR ATTACH.

Step 3: Remove Duplicate File References Manually

  • Open SQL Server Management Studio (SSMS) and connect via DAC (Dedicated Admin Connection) using ADMIN:ServerName.
  • Query sys.master_files and sys.dm_db_brick_files to identify the duplicate physical_name entry.
  • Use ALTER DATABASE ... MODIFY FILE to repoint the orphaned file reference to a single, correct brick path (e.g., \\Brick02\SQLData\yourfile.mdf).
  • Delete the orphaned duplicate file copy from the incorrect brick path using File Explorer or Remove-Item in PowerShell.

Step 4: Rebuild Brick Mapping Table

  • If the duplication persists, run DBCC REBUILD_BRICKMAP ('YourDatabaseName') to force SQL Server 2025 to regenerate the brick-to-file mapping table from scratch.
  • Take the database offline first: ALTER DATABASE YourDatabaseName SET OFFLINE WITH ROLLBACK IMMEDIATE.
  • Bring it back online once the rebuild completes: ALTER DATABASE YourDatabaseName SET ONLINE.

Alternative or Verification Steps

  • Verify the fix by re-running the CREATE DATABASE ... FOR ATTACH command and confirming the database mounts without Error 1850, then check sys.dm_db_brick_files to ensure each file maps to exactly one brick.
  • If the issue persists, detach the database entirely, manually copy all data/log files to a single consolidated brick location, and perform a fresh attach operation specifying explicit FILENAME paths in the CREATE DATABASE statement.

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

Troubleshooting Guide: SQL Server Error 1849

Why This Error Happens

This error occurs because SQL Server does not allow a new database to be created with FILESTREAM filegroups if the model database has either ALLOW_SNAPSHOT_ISOLATION or READ_COMMITTED_SNAPSHOT enabled. Since every new database inherits its initial settings and structure from model, these isolation level settings are fundamentally incompatible with the row-versioning mechanisms required by FILESTREAM filegroups. This is a design restriction in SQL Server 2025, not a bug, and it will block the CREATE DATABASE statement until the conflicting settings are resolved.

Step-by-Step Resolution Guide

Step 1: Verify the Current Isolation Settings on the Model Database

  • Open SQL Server Management Studio (SSMS) and connect to your SQL Server 2025 instance.
  • Run the following query to check current settings:
  SELECT name, snapshot_isolation_state, is_read_committed_snapshot_on
  FROM sys.databases
  WHERE name = 'model';
  • Confirm that either snapshot_isolation_state or is_read_committed_snapshot_on returns a value of 1 (ON).

Step 2: Disable Snapshot Isolation and Read-Committed Snapshot on Model

  • Ensure no active connections or transactions are running against the model database before making changes.
  • Execute the following T-SQL commands to turn both settings OFF:
  ALTER DATABASE model SET ALLOW_SNAPSHOT_ISOLATION OFF;
  ALTER DATABASE model SET READ_COMMITTED_SNAPSHOT OFF;
  • If you receive a blocking error, you may need to set the database to SINGLE_USER mode temporarily:
  ALTER DATABASE model SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

Step 3: Retry the CREATE DATABASE Statement

  • Switch model back to MULTI_USER mode if you changed it in Step 2:
  ALTER DATABASE model SET MULTI_USER;
  • Re-run your original CREATE DATABASE command that includes the FILESTREAM filegroup declaration.
  • Confirm the database is created successfully without Error 1849 appearing in the Messages pane.

Step 4: Check Windows Server FILESTREAM Configuration (If Issue Persists)

  • Open SQL Server Configuration Manager on Windows Server 2025 or Windows 11.
  • Navigate to SQL Server Services, right-click your instance, and select Properties.
  • Go to the FILESTREAM tab and ensure Enable FILESTREAM for Transact-SQL access is checked.
  • Restart the SQL Server service for changes to take effect.

Alternative or Verification Steps

  • To verify the fix, run SELECT name, snapshot_isolation_state_desc, is_read_committed_snapshot_on FROM sys.databases WHERE name = 'model'; and confirm both values show OFF or 0.
  • As an alternative, if you need snapshot isolation for other databases, create the FILESTREAM-enabled database first, then enable ALLOW_SNAPSHOT_ISOLATION on that specific user database afterward—just not on model itself.

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

Troubleshooting Guide: SQL Server Error 1848 — VSS Auto-Recovered Snapshot Failure for Online DBCC Check

Why This Error Happens

Error 1848 occurs when SQL Server’s internal use of the Volume Shadow Copy Service (VSS) fails while attempting to create a transient, auto-recovered snapshot needed to run DBCC CHECKDB in online mode. This typically happens because the VSS service is disabled, the SQL Server VSS Writer is not registered or running, or the SQL Server service account lacks the necessary permissions on the volume hosting the database files. It can also occur due to insufficient free space on the volume, a corrupted VSS writer registration, or conflicts with third-party backup/snapshot software that is holding a lock on the VSS framework.

Step-by-Step Resolution Guide

Step 1: Verify VSS and SQL Server VSS Writer Services Are Running

  • Open an elevated Command Prompt and run vssadmin list writers to confirm “SQL Server VSS Writer” is listed and shows no errors.
  • If the writer is missing, open services.msc and ensure both “Volume Shadow Copy” and “SQL Server VSS Writer” services are set to Automatic and are currently running.
  • Restart the SQL Server VSS Writer service with net stop "SQL Server VSS Writer" followed by net start "SQL Server VSS Writer".

Step 2: Check SQL Server Service Account Permissions

  • Confirm the SQL Server service account has read/write access to the data and log file directories (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\).
  • Verify the account is a member of the local “Backup Operators” group, which is required for VSS snapshot operations.
  • Use icacls "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA" to inspect and, if needed, grant Modify permissions to the SQL service account.

Step 3: Re-register the VSS Framework and SQL Writer DLL

  • Run net stop "SQL Server VSS Writer" then re-register the writer DLL using regsvr32 sqlvdi.dll from the SQL Server Binn directory (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\).
  • Re-register the core VSS components with vssvc /register from an elevated prompt.
  • Restart the “SQL Server VSS Writer” and “Volume Shadow Copy” services, then re-run vssadmin list writers to confirm a clean state.

Step 4: Free Up Disk Space and Resolve Volume Conflicts

  • Check the volume hosting the database files for at least 10–15% free space, since VSS requires shadow storage space to create snapshots.
  • Run vssadmin list shadowstorage to review current shadow copy allocation and adjust with vssadmin resize shadowstorage /for=C: /on=C: /maxsize=20% if needed.
  • Temporarily disable or exclude SQL Server data volumes from any third-party backup or antivirus software that may be locking VSS resources during the DBCC check window.

Step 5: Rerun the Online DBCC Check

  • Execute DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS in SQL Server Management Studio while the database remains online.
  • Monitor the SQL Server Error Log and Windows Event Viewer (Application log) during execution to confirm Error 1848 no longer appears.

Alternative or Verification Steps

  • Run vssadmin list writers immediately before and after the DBCC check; a healthy state shows “SQL Server VSS Writer” with “No error” status and a stable writer ID.
  • If the error persists, run DBCC CHECKDB in offline mode (take the database into single-user mode via ALTER DATABASE ... SET SINGLE_USER WITH ROLLBACK IMMEDIATE) as a workaround, then investigate VSS provider conflicts using vssadmin list providers.

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

Why This Error Happens

Error 1847 occurs when SQL Server 2025 detects that a database is running on an auto-recovered Volume Shadow Copy (VSS) snapshot, which is a transient, OS-generated snapshot type that Windows Server 2025/Windows 11 does not fully support for persistent database operations. This typically happens after a system crash or improper hibernation/resume cycle where the OS automatically mounts a shadow copy to recover the volume state. SQL Server’s engine blocks startup on these auto-recovered snapshots because they lack the write-consistency guarantees required for transactional integrity.

Step-by-Step Resolution Guide

Step 1: Identify the Auto-Recovered Snapshot

  • Open an elevated Command Prompt and run vssadmin list shadows to check for active shadow copies.
  • Look for entries labeled “Auto-Recovered” in the shadow copy metadata output.
  • Cross-reference the volume path reported in the SQL Server error log (usually found at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).

Step 2: Remove or Remount the Affected Volume Correctly

  • Run vssadmin delete shadows /For=<VolumeLetter>: /Oldest to clear the problematic auto-recovered snapshot.
  • Ensure the underlying disk was not improperly disconnected (check Disk Management via diskmgmt.msc) during the last shutdown.
  • Reboot the server normally (avoid Fast Startup/Hibernation) to prevent Windows from regenerating an auto-recovered snapshot on next boot.

Step 3: Disable Fast Startup and Hibernation-Based Recovery

  • Navigate to Control Panel > Power Options > Choose what the power buttons do.
  • Uncheck Turn on fast startup (recommended) under Shutdown Settings.
  • Alternatively, run powercfg /hibernate off in an elevated Command Prompt to fully disable hibernation, which prevents Windows from creating these problematic snapshot states.

Step 4: Restart SQL Server and Validate Database Mount

  • Restart the SQL Server service via services.msc or run net stop MSSQLSERVER && net start MSSQLSERVER.
  • Check the SQL Server error log again to confirm Error 1847 no longer appears during the mount process.
  • Bring any affected databases back online using ALTER DATABASE [YourDB] SET ONLINE; in SQL Server Management Studio (SSMS).

Alternative or Verification Steps

  • Verify the fix by running sys.dm_os_volume_stats in SSMS to confirm the database files are reporting from a standard (non-shadow-copy) volume path.
  • If the error persists, restore the database from the last known-good native SQL Server backup (.bak file) onto a standard NTFS volume rather than relying on VSS-based recovery.

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

Troubleshooting Guide: Error 1846 – Cannot Find SQL VSS Writer Component

Why This Error Happens

This error occurs when the SQL Server VSS Writer service (SQLWriter) is either stopped, disabled, or not registered properly with the Volume Shadow Copy Service (VSS) subsystem on Windows Server 2025 / Windows 11. It can also happen if the VSS writer registry entries are corrupted, or if DBCC CHECKDB’s internal auto-recovery snapshot process cannot communicate with the writer due to permission restrictions on the service account. Additionally, a mismatch between the SQL Server instance version and the installed SQLWriter binaries can cause the writer to silently fail to register.

Step-by-Step Resolution Guide

Step 1: Verify the SQL Server VSS Writer Service Status

  • Open Services.msc on the affected Windows Server 2025 / Windows 11 machine.
  • Locate SQL Server VSS Writer (SQLWriter) in the list.
  • Ensure the Startup Type is set to Automatic and the service Status is Running.
  • If stopped, right-click and select Start, then attempt the DBCC CHECKDB operation again.

Step 2: Re-register the VSS Writer with the Operating System

  • Open an elevated Command Prompt (Run as Administrator).
  • Stop the writer service first:
  net stop SQLWriter
  • Re-register the VSS writer DLL manually:
  regsvr32 "C:\Program Files\Microsoft SQL Server\160\Shared\sqlvdi.dll"
  • Restart the service:
  net start SQLWriter

Step 3: Validate VSS Writer Visibility via Command Line

  • Run the following command to confirm SQL Server appears in the writer list:
  vssadmin list writers
  • Look for an entry named SqlServerWriter with a State of [1] Stable and no error codes.
  • If the writer is missing entirely, proceed to repair the SQL Server instance using the SQL Server Installation Center > Repair option.

Step 4: Check Service Account Permissions

  • Confirm the account running SQLWriter (typically NT AUTHORITY\SYSTEM or LocalSystem) has sufficient rights to access the SQL Server data directories.
  • Navigate to Local Security Policy > User Rights Assignment and verify the account has “Back up files and directories” and “Restore files and directories” permissions.
  • Restart both the SQL Server service and SQLWriter service after any permission changes.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS and confirm Error 1846 no longer appears in the SQL Server error log or Windows Event Viewer.
  • If the issue persists, use DBCC CHECKDB WITH TABLOCK as a temporary workaround, which bypasses the VSS snapshot mechanism entirely by using a database-wide lock instead of auto-recovered snapshots.

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

Troubleshooting Guide: Error 1845 — SQL VSS Writer Not Found in Metadata Document

Why This Error Happens

This error occurs when the SQLWriter service is either stopped, disabled, or not registered correctly with the Volume Shadow Copy Service (VSS) at the time an automated snapshot is requested for an online DBCC check. It can also result from a corrupted VSS writer registration cache, conflicting third-party backup software that unregisters SQL Server’s writer, or incomplete permissions on the service account running SQLWriter. Since SQL Server 2025 relies on this writer to quiesce I/O during snapshot-based consistency checks, its absence immediately causes VSS to fail metadata lookup.

Step-by-Step Resolution Guide

Step 1: Verify the SQLWriter Service Status

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate SQL Server VSS Writer (SQLWriter) and confirm the status is “Running” and Startup Type is set to “Automatic.”
  • If stopped, right-click and select Start, then re-run the DBCC check to see if the error persists.

Step 2: Re-register the SQL Writer with VSS

  • Open an elevated Command Prompt and stop the service:
  net stop SQLWriter
  • Re-register the writer binary manually:
  "C:\Program Files\Microsoft SQL Server\160\Shared\sqlwriter.exe" /regserver
  • Restart the service:
  net start SQLWriter

Step 3: Rebuild the VSS Writer Metadata Cache

  • Open an elevated Command Prompt and stop all VSS-related services (VSS, SQLWriter, and any third-party backup agent services).
  • Clear the VSS writer cache by restarting the Volume Shadow Copy service:
  net stop VSS
  net start VSS
  • Confirm the SQL writer now appears by running:
  vssadmin list writers

Step 4: Check Service Account Permissions

  • Ensure the account running SQLWriter (typically Local System) has not been altered via Group Policy or local security policy.
  • Navigate to Local Security Policy > Local Policies > User Rights Assignment and confirm “Log on as a service” includes the required system accounts.
  • Reboot the server if permissions were modified, as VSS writer registration occurs at boot/service-start time.

Step 5: Update SQL Server 2025 Cumulative Update

  • Confirm you are on the latest Cumulative Update (CU) for SQL Server 2025, as early builds had a known VSS writer registration timing bug.
  • Install the latest CU from the official Microsoft Download Center.
  • Restart the SQL Server and SQLWriter services after installation completes.

Alternative or Verification Steps

  • Run vssadmin list writers from an elevated prompt and confirm SqlServerWriter appears with a state of “[1] Stable” and no error flags.
  • If the writer still fails to register, temporarily disable any third-party backup or antivirus software that hooks into VSS, then repeat Steps 2–3 to isolate whether an external agent is unregistering the SQL writer.

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

Why This Error Happens

Error 1844 is a generic template error that SQL Server throws when a specific feature, API, or configuration option is invoked on a platform or edition that does not support it. In SQL Server 2025 running on Windows Server 2025 or Windows 11, this most commonly occurs when a feature (such as a specific In-Memory OLTP component, PolyBase connector, or an Enterprise-only capability) is called against a Standard/Express edition instance, a Server Core installation lacking required binaries, or an unsupported OS build. It can also surface when backward-compatible T-SQL syntax or extended stored procedures reference functionality that has been deprecated or restricted on newer OS/SQL builds.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Feature and Platform Named in the Error

  • Run the triggering query or operation again and capture the full expanded error text (the %ls placeholders will resolve to the actual feature name and OS/edition name).
  • Cross-reference the feature name against Microsoft’s SQL Server 2025 Features Supported by Edition documentation.
  • Check SQL Server error log for additional context: EXEC sp_readerrorlog 0, 1, 'is not supported';

Step 2: Verify SQL Server Edition and Installation Type

  • Run SELECT SERVERPROPERTY('Edition'), SERVERPROPERTY('EngineEdition'); to confirm whether you’re on Standard, Web, Express, or Enterprise.
  • If the feature requires Enterprise Edition (e.g., certain In-Memory OLTP or advanced PolyBase features), you must upgrade the edition using Setup.exe /ACTION=EDITIONUPGRADE and a valid Enterprise PID key.
  • If running on Server Core, confirm the required feature binaries are installed by checking C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\ for the relevant DLLs; some GUI-dependent features are intentionally blocked on Core installs.

Step 3: Validate OS Compatibility and Apply Updates

  • Confirm Windows Server 2025 / Windows 11 build number via winver or Get-ComputerInfo | Select WindowsVersion, OsBuildNumber in PowerShell.
  • Apply the latest Windows Cumulative Update and the latest SQL Server 2025 Cumulative Update (CU) from the Microsoft Update Catalog, since early CUs sometimes mis-flag supported features as unsupported due to version-detection bugs.
  • Restart the SQL Server service after patching: Restart-Service MSSQLSERVER -Force.

Step 4: Reconfigure or Replace the Unsupported Feature Call

  • If the feature is confirmed unsupported on your edition/OS combination permanently, modify the T-SQL script or application connection string to avoid invoking it.
  • For deprecated syntax, consult the SQL Server 2025 Breaking Changes documentation and replace with the recommended modern equivalent (e.g., swap deprecated system stored procedures for catalog views).

Alternative or Verification Steps

  • Re-run the original operation/query after each change and confirm Error 1844 no longer appears in sys.messages output or the SQL Server error log.
  • If the issue persists, test the same operation on a clean Enterprise Edition instance on a fully patched Windows Server 2025 (Desktop Experience, not Core) to isolate whether the limitation is edition-based or OS-based.

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

Why This Error Happens

Error 1843 is not actually a failure condition — it is an informational message that SQL Server raises during a RESTORE DATABASE... FROM DATABASE_SNAPSHOT operation. It confirms that the engine has successfully located the split point LSN (Log Sequence Number) where the live database diverged from the snapshot and is rolling the data pages back to that exact point in time. Administrators often mistake this message in the error log or Event Viewer for a genuine corruption or permission error because it is logged with a numbered “Error” severity level despite being purely informational.

Step-by-Step Resolution Guide

Step 1: Confirm the Message Severity and Context

  • Open SQL Server Management Studio (SSMS) and check the Messages tab after running the revert command.
  • Verify the severity state reads State 1 and the text explicitly says “This is an informational message only. No user action is required.”
  • Cross-reference the timestamp in the SQL Server Error Log (Management > SQL Server Logs in SSMS) against the time you initiated the snapshot revert.

Step 2: Validate the Snapshot Revert Actually Completed

  • Run the following query to confirm the primary database state is back online:
  • SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabaseName';
  • The state_desc column should read ONLINE, confirming the revert finished rather than hanging mid-operation.
  • Check sys.fn_dblog() if deeper validation of the LSN split point is required for compliance logging.

Step 3: Check for Underlying Snapshot File Issues (If Revert Fails)

  • If the revert operation actually fails (rather than just logging 1843), inspect the physical snapshot file path.
  • Navigate to the default snapshot directory, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • Confirm the .ss snapshot file is not marked Read-Only or locked by another process using Windows Resource Monitor.

Step 4: Clear Stale Error Log Noise (Optional Cleanup)

  • If Error 1843 is cluttering monitoring dashboards (e.g., SCOM, SolarWinds), suppress Event ID 1843 specifically at the monitoring agent level.
  • Do not suppress all SQL Server 1843-series events globally, as this may mask unrelated issues in future patches.

Alternative or Verification Steps

  • Run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; post-revert to ensure no actual data page corruption occurred during the point-in-time rollback.
  • If you need the revert operation to run silently without logging this message, use RESTORE DATABASE ... WITH NORECOVERY followed by a manual recovery step instead of a direct snapshot revert, which changes how the engine reports split-point completion.

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

Troubleshooting Guide: Error 1408 – Database Not Recovered Far Enough for Mirroring/Availability Group

Why This Error Happens

This error occurs when the secondary (mirror) database is missing one or more transaction log backups that have already been applied or generated on the principal/primary database, causing a gap in the log chain. It commonly happens when a full backup was taken on the principal after the mirroring/AG setup began, or when a log backup in the restore sequence was skipped, corrupted, or never restored on the secondary with NORECOVERY. SQL Server requires an unbroken, sequential log chain on the secondary before it can safely synchronize with the principal.

Step-by-Step Resolution Guide

Step 1: Verify the Log Chain on the Principal Database

  • Open SQL Server Management Studio (SSMS) and connect to the principal replica.
  • Run the following query to check the backup history and LSN sequence:
SELECT backup_start_date, database_name, type, backup_set_id, last_lsn
FROM msdb.dbo.backupset
WHERE database_name = 'YourDatabaseName'
ORDER BY backup_start_date DESC;
  • Identify the last log backup successfully restored on the secondary and confirm no gaps exist afterward.

Step 2: Take a Fresh Full Backup and Restore Chain

  • On the principal, take a new full backup:
BACKUP DATABASE [YourDatabaseName] 
TO DISK = 'C:\Backups\YourDatabaseName_Full.bak' 
WITH COPY_ONLY, INIT;
  • Immediately follow with a transaction log backup:
BACKUP LOG [YourDatabaseName] 
TO DISK = 'C:\Backups\YourDatabaseName_Log.trn';
  • Copy both backup files to the secondary server (e.g., using robocopy or a shared network path).

Step 3: Restore the Backups on the Secondary with NORECOVERY

  • Restore the full backup first:
RESTORE DATABASE [YourDatabaseName] 
FROM DISK = 'C:\Backups\YourDatabaseName_Full.bak' 
WITH NORECOVERY, REPLACE;
  • Apply the log backup immediately after:
RESTORE LOG [YourDatabaseName] 
FROM DISK = 'C:\Backups\YourDatabaseName_Log.trn' 
WITH NORECOVERY;
  • Ensure no additional log backups were taken on the principal between these steps (this breaks the chain again).

Step 4: Re-Join the Database to the Mirror or Availability Group

  • For Database Mirroring, re-run the mirroring setup:
ALTER DATABASE [YourDatabaseName] 
SET PARTNER = 'TCP://SecondaryServer:5022';
  • For an Availability Group, re-join the database:
ALTER DATABASE [YourDatabaseName] SET HADR AVAILABILITY GROUP = [YourAGName];
  • Check Windows Server 2025 Firewall rules to confirm the mirroring/AG endpoint port (default 5022) is open between nodes.

Alternative or Verification Steps

  • Verify synchronization status using SELECT * FROM sys.dm_hadr_database_replica_states; (for AGs) or check the Database Mirroring Monitor in SSMS — the state should show “Synchronized” or “Synchronizing.”
  • If the gap persists due to automated log backup jobs on the principal, temporarily disable the SQL Agent log backup job during the restore window to prevent new LSN gaps from forming.

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

Why This Error Happens

Error 1407 occurs when SQL Server attempts to establish or resume database mirroring or an Always On Availability Group relationship, but the LSN (Log Sequence Number) chain or database GUID on the secondary/remote copy does not match the primary database’s lineage. This typically happens when the secondary database was restored from a different backup chain, the database ID/recovery fork GUID was broken by an intermediate restore, or the mirroring/AG metadata became desynchronized due to a failed failover. It can also surface after a database was dropped and recreated locally without re-establishing the mirroring partnership properly.

Step-by-Step Resolution Guide

Step 1: Verify the Backup Lineage and Recovery Fork

  • Run RESTORE HEADERONLY against the last full and log backups to confirm the DatabaseBackupLSN and FirstLSN values align between primary and secondary.
  • Check sys.database_recovery_status and compare last_log_backup_lsn on both instances using: SELECT database_id, last_log_backup_lsn FROM sys.database_recovery_status;
  • Confirm no out-of-band restores (e.g., a manual restore from an older backup set) broke the chain.

Step 2: Remove the Broken Mirroring/AG Partnership

  • On the primary, run: ALTER DATABASE [YourDB] SET PARTNER OFF; (for legacy mirroring) or remove the database from the Availability Group via ALTER AVAILABILITY GROUP [AGName] REMOVE DATABASE [YourDB];
  • On the secondary instance, drop the orphaned database copy: DROP DATABASE [YourDB];
  • Clear any stale endpoint sessions in SQL Server Configuration Manager if mirroring sessions remain listed as “Suspended.”

Step 3: Re-Seed the Secondary Database from a Fresh Full Backup

  • Take a new full backup on the primary: BACKUP DATABASE [YourDB] TO DISK = 'D:\Backups\YourDB_Full.bak';
  • Restore it on the secondary using WITH NORECOVERY: RESTORE DATABASE [YourDB] FROM DISK = 'D:\Backups\YourDB_Full.bak' WITH NORECOVERY;
  • Apply any subsequent transaction log backups in sequence, also WITH NORECOVERY, ensuring no gaps in the LSN chain.

Step 4: Re-Establish the Partnership or Add Back to the Availability Group

  • For mirroring, re-run the ALTER DATABASE [YourDB] SET PARTNER = 'TCP://SecondaryServer:5022'; command on the primary.
  • For Always On AG, use ALTER AVAILABILITY GROUP [AGName] ADD DATABASE [YourDB]; on the primary after the secondary is in a restoring state.
  • Confirm firewall rules on Windows Server 2025 allow the mirroring endpoint port (default 5022) through New-NetFirewallRule -DisplayName "SQL Mirroring" -Direction Inbound -LocalPort 5022 -Protocol TCP -Action Allow.

Alternative or Verification Steps

  • Check the “Always On Availability Groups” dashboard in SSMS or query sys.dm_hadr_database_replica_states to confirm synchronization_state returns SYNCHRONIZED or SYNCHRONIZING with no errors.
  • If re-seeding fails repeatedly, use the Automatic Seeding feature (ALTER AVAILABILITY GROUP ... MODIFY REPLICA ... WITH (SEEDING_MODE = AUTOMATIC)) to let SQL Server handle the full data transfer and avoid manual backup/restore mismatches.

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

Troubleshooting Guide: SQL Server Error 1406 — Unable to Force Service Safely in Database Mirroring

Why This Error Happens

This error occurs when an administrator attempts to force service (manually fail over) to a mirror database, but SQL Server detects that doing so could result in data loss or an inconsistent state between the principal and mirror databases. It typically happens when the mirroring session is in a SYNCHRONIZING state (rather than SYNCHRONIZED) at the time of the failure, meaning the mirror does not have a fully caught-up copy of the transaction log. SQL Server blocks the forced failover as a safety mechanism to prevent committing to a database copy that is behind the principal.

Step-by-Step Resolution Guide

Step 1: Verify the Mirroring State Before Taking Action

  • Open SQL Server Management Studio (SSMS) and connect to the mirror server instance.
  • Run the following query to check the mirroring state:
SELECT DB_NAME(database_id) AS DatabaseName, mirroring_state_desc, mirroring_role_desc
FROM sys.database_mirroring
WHERE mirroring_guid IS NOT NULL;
  • Confirm whether the state is SYNCHRONIZED or SYNCHRONIZING. If it is SYNCHRONIZING, forcing service will cause data loss, which is why SQL Server is blocking the action.

Step 2: Remove Mirroring Safely from the Mirror Database

  • On the mirror server instance, open a new query window in SSMS.
  • Execute the command to break the mirroring partnership:
ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;
  • This detaches the database from the mirroring session without attempting an unsafe automatic failover.

Step 3: Recover the Database to Bring It Online

  • With mirroring removed, the database will be left in a RESTORING state. Run the recovery command to bring it online:
RESTORE DATABASE [YourDatabaseName] WITH RECOVERY;
  • This rolls forward any committed transactions and rolls back uncommitted ones, making the database accessible.
  • If the database was part of an Availability Group migration or legacy mirroring setup in Windows Server 2025, confirm no lingering endpoint configurations exist by checking sys.database_mirroring_endpoints.

Step 4: Validate Application and Service Connectivity

  • Update any connection strings or SQL Server Agent jobs that referenced the old mirroring partner or failover partner connection string.
  • Restart the SQL Server service (via services.msc or net stop MSSQLSERVER / net start MSSQLSERVER) on Windows Server 2025 to clear any cached mirroring session states.
  • Check the SQL Server Error Log (Management > SQL Server Logs in SSMS) for confirmation messages that mirroring has been removed and the database is online.

Alternative or Verification Steps

  • Run SELECT state_desc FROM sys.databases WHERE name = 'YourDatabaseName'; and confirm the result shows ONLINE rather than RESTORING or SUSPECT.
  • If the database still won’t come online after recovery, consider restoring from the most recent full backup plus transaction log backups as an alternative to salvage the mirror copy.

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

Troubleshooting Guide: Error 1405 – Database Already Enabled for Database Mirroring

Why This Error Happens

Error 1405 occurs when an administrator attempts to run ALTER DATABASE ... SET PARTNER or re-initialize mirroring on a database that already has an active mirroring session configured in SQL Server 2025. This typically happens because mirroring metadata still exists in the system catalog (sys.database_mirroring) even if the session appears broken or was improperly removed. It can also occur when a database was restored from a backup that retained mirroring endpoint references, or when a previous SET PARTNER OFF command failed to fully clear the mirroring state.

Step-by-Step Resolution Guide

Step 1: Verify Current Mirroring State

  • Open SQL Server Management Studio (SSMS) and connect to the instance via Windows 11 or Windows Server 2025.
  • Run the following query to check mirroring status:
  SELECT name, mirroring_state_desc, mirroring_partner_instance 
  FROM sys.database_mirroring 
  WHERE database_id = DB_ID('YourDatabaseName');
  • Confirm whether mirroring_state_desc shows SYNCHRONIZED, SUSPENDED, or a non-NULL value indicating an active configuration.

Step 2: Remove the Existing Mirroring Configuration

  • Execute the command to safely break the existing mirroring session before reconfiguring:
  ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;
  • If the command fails due to connectivity issues with the partner server, force removal locally:
  ALTER DATABASE [YourDatabaseName] SET PARTNER OFF WITH NO_WAIT;
  • Wait 10-15 seconds to allow SQL Server to clear internal mirroring metadata.

Step 3: Validate Endpoint and Service Account Configuration

  • Navigate to SQL Server Configuration Manager on Windows Server 2025 and verify the Database Mirroring Endpoint is still listening (default port 5022).
  • Check for orphaned endpoints using:
  SELECT * FROM sys.database_mirroring_endpoints;
  • If an endpoint conflict exists, drop and recreate it:
  DROP ENDPOINT [Mirroring];
  CREATE ENDPOINT [Mirroring] STATE = STARTED AS TCP (LISTENER_PORT = 5022) 
  FOR DATABASE_MIRRORING (ROLE = ALL);

Step 4: Re-Establish Mirroring (If Required)

  • Once the old configuration is cleared, re-run the setup on both the principal and mirror servers:
  ALTER DATABASE [YourDatabaseName] SET PARTNER = 'TCP://MirrorServer:5022';
  • Ensure certificates or Windows Authentication trusts between the principal and mirror instances are valid and have not expired.

Alternative or Verification Steps

  • Re-run the SELECT * FROM sys.database_mirroring query to confirm mirroring_state_desc now shows NULL (if removed) or SYNCHRONIZED (if successfully re-established).
  • If Error 1405 persists, restart the SQL Server service via Services.msc on Windows Server 2025 to force a refresh of cached mirroring metadata, then repeat Step 2.

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

Troubleshooting Guide: Error 1404 — Database Mirror Is Busy (SQL Server 2025)

Why This Error Happens

Error 1404 occurs when SQL Server 2025 attempts to execute a mirroring-related command (such as altering mirroring state, failover, or removing a mirror) while the mirroring session is still processing a prior state transition or synchronizing log data between the principal and mirror databases. This is typically caused by high transaction log send/redo queue latency, a slow or saturated network link between replicas, or the mirror database still being in the process of rolling forward transactions. It can also occur if a previous mirroring command (like ALTER DATABASE SET PARTNER OFF) was issued while an automatic failover or role-switch was already in progress internally.

Step-by-Step Resolution Guide

Step 1: Confirm Current Mirroring State and Role

  • Run the following query on the principal server to check session health:
  SELECT DB_NAME(database_id) AS DatabaseName, mirroring_state_desc, mirroring_role_desc, mirroring_connection_timeout, mirroring_redo_queue_size, mirroring_witness_state_desc
  FROM sys.database_mirroring
  WHERE mirroring_guid IS NOT NULL;
  • Confirm mirroring_state_desc is SYNCHRONIZED before issuing further commands.
  • If the state shows SYNCHRONIZING or PENDING_FAILOVER, the session is still busy and not ready for additional commands.

Step 2: Wait Out the Synchronization Window or Reduce Redo Backlog

  • Check mirroring_redo_queue_size and mirroring_log_send_queue_size in sys.database_mirroring — large values indicate the mirror is catching up.
  • On Windows Server 2025, verify network throughput between nodes using Get-NetAdapterStatistics in PowerShell to rule out bandwidth saturation.
  • Avoid issuing ALTER DATABASE, failover, or mirroring removal commands until queue sizes trend toward zero.

Step 3: Retry the Command with a Controlled Delay

  • Re-issue the exact command that failed (e.g., ALTER DATABASE <DBName> SET PARTNER FAILOVER;) only after confirming SYNCHRONIZED state.
  • Example retry wrapper in T-SQL:
  WAITFOR DELAY '00:00:30';
  ALTER DATABASE YourDB SET PARTNER OFF;
  • If using SQL Server Agent jobs or automation scripts, add a retry loop with exponential backoff (e.g., 15s, 30s, 60s) rather than an immediate retry.

Step 4: Check SQL Server Error Log and Windows Event Viewer

  • Open Event Viewer > Applications and Services Logs > MSSQLSERVER on Windows Server 2025 to look for correlating mirroring timeout or network drop entries (Event ID 1474, 1479, or 1443).
  • Cross-reference timestamps with the 1404 error to identify if a network blip or endpoint authentication failure (Kerberos/Certificate) triggered the busy state.

Step 5: Validate Mirroring Endpoint Configuration

  • Confirm the mirroring endpoint is STARTED on both instances:
  SELECT name, state_desc, port FROM sys.database_mirroring_endpoints;
  • Ensure the endpoint port (commonly 5022) is not blocked by Windows Defender Firewall — verify with:
  Get-NetFirewallRule -DisplayName "*SQL Mirroring*"

Alternative or Verification Steps

  • After retrying, re-run the sys.database_mirroring query to confirm mirroring_state_desc = SYNCHRONIZED and that the original command now completes without Error 1404.
  • If the issue persists across multiple retries, consider switching from High-Safety (synchronous) mode to High-Performance (asynchronous) mode temporarily via ALTER DATABASE ... SET PARTNER SAFETY OFF to reduce commit latency, then switch back once backlog clears.

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

Why This Error Happens

Error 1403 occurs when the witness server in a database mirroring session cannot validate the state response from the principal or mirror instance, typically due to network connectivity interruptions between the three mirroring partners. This is commonly caused by expired or mismatched security certificates, firewall rules blocking the mirroring endpoint port (default 5022), or a mismatch in the database mirroring endpoint state (STOPPED vs STARTED) on one of the instances. In some cases, this also surfaces when the witness instance service account lacks the CONNECT permission on the mirroring endpoint of the partner servers.

Step-by-Step Resolution Guide

Step 1: Verify Endpoint Status and Connectivity

  • Run SELECT * FROM sys.database_mirroring_endpoints; on all three instances (Principal, Mirror, Witness) to confirm state_desc is STARTED.
  • Use Test-NetConnection -ComputerName <ServerName> -Port 5022 in PowerShell on Windows Server 2025 to confirm the firewall isn’t blocking the mirroring port.
  • Check Windows Defender Firewall advanced settings to ensure an inbound rule exists for TCP port 5022 on all three nodes.

Step 2: Validate Login Permissions on the Endpoint

  • Ensure the service account running the Witness SQL Server instance has an associated login on both the Principal and Mirror instances.
  • Grant connect permissions by running:
  GRANT CONNECT ON ENDPOINT::Mirroring TO [DOMAIN\ServiceAccount];
  • Repeat this step on all three servers involved in the mirroring session to rule out a permission mismatch.

Step 3: Re-validate Certificates (For Non-Domain Configurations)

  • If using certificate-based authentication (common in Windows 11 lab setups or cross-domain Windows Server 2025 instances), verify the certificate expiration date using SELECT * FROM sys.certificates;.
  • Re-issue and back up/restore the certificate across all three instances if expired.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc or Restart-Service MSSQLSERVER after certificate updates.

Step 4: Remove and Re-establish the Witness

  • Temporarily remove the witness server from the mirroring session to force a clean state reset:
  ALTER DATABASE [YourDB] SET WITNESS OFF;
  • Re-add the witness once connectivity and permissions are confirmed:
  ALTER DATABASE [YourDB] SET WITNESS = N'TCP://WitnessServerName:5022';

Alternative or Verification Steps

  • Check the SQL Server Error Log and Windows Event Viewer (Application Log) on the Witness instance immediately after re-adding the witness; a successful quorum establishment confirms the fix.
  • If the error persists, run the Database Mirroring Monitor (sp_dbmmonitorresults) to view the historical status and pinpoint which specific partner is rejecting the witness handshake.

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

Troubleshooting Guide: Database Mirroring Error 1402

Why This Error Happens

Error 1402 occurs when the witness server instance has a different understanding of the database mirroring session’s configuration than the principal or mirror server, typically because the witness’s metadata still references an old mirroring GUID. This mismatch commonly arises after a mirroring session was dropped and recreated without the witness being properly removed and re-added, leaving stale configuration data in the witness’s system catalogs. It can also occur due to replication latency between the partners and the witness during failover events, or because of DNS/network name resolution issues causing the witness to communicate with an unexpected instance.

Step-by-Step Resolution Guide

Step 1: Remove the Witness from the Mirroring Session

  • Connect to the principal server using SQL Server Management Studio (SSMS) or sqlcmd on Windows Server 2025.
  • Run the following T-SQL command to detach the witness cleanly:
  ALTER DATABASE [YourDatabaseName] SET WITNESS OFF;
  • Verify the witness status is removed by checking sys.database_mirroring on the principal.

Step 2: Clear Stale Mirroring Metadata on the Witness Instance

  • On the witness SQL Server instance, query sys.database_mirroring_witnesses to confirm the stale GUID entry:
  SELECT * FROM sys.database_mirroring_witnesses;
  • If an orphaned entry exists for the database name in question, restart the SQL Server service on the witness instance via Services.msc or:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • This clears the witness’s cached in-memory mirroring GUID table, forcing it to rebuild on reconnection.

Step 3: Re-establish the Witness Role

  • On the principal server, re-add the witness using the fully qualified domain name (FQDN) or correct port to avoid name resolution mismatches:
  ALTER DATABASE [YourDatabaseName] SET WITNESS = 'TCP://WitnessServerFQDN:5022';
  • Ensure the endpoint port (default 5022) is not blocked by Windows Firewall on Windows Server 2025 — check via Windows Defender Firewall with Advanced Security.
  • Confirm the mirroring endpoint state is “STARTED” on all three instances using:
  SELECT name, state_desc FROM sys.database_mirroring_endpoints;

Step 4: Validate Certificate and Login Mappings (If Using Certificate-Based Authentication)

  • If mirroring endpoints use certificates rather than Windows Authentication, confirm the certificates have not expired by checking sys.certificates on all three servers.
  • Re-issue and re-map certificates if expired, then re-grant CONNECT permission on the mirroring endpoint to the appropriate login:
  GRANT CONNECT ON ENDPOINT::Mirroring TO [DOMAIN\WitnessServiceAccount];

Alternative or Verification Steps

  • After completing the steps above, verify the fix by checking the mirroring status in SSMS under Database Properties > Mirroring, confirming the state reads “Synchronized” with the witness connected.
  • If the error persists, drop the entire mirroring session on all three servers (ALTER DATABASE SET PARTNER OFF and SET WITNESS OFF) and reconfigure mirroring from scratch using the Database Mirroring Wizard to eliminate any residual GUID conflicts.

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

Troubleshooting Guide: Error 1401 — Database-Mirroring Master Thread Startup Failure

Why This Error Happens

Error 1401 typically occurs when the database-mirroring endpoint cannot initialize correctly, often due to port conflicts, blocked firewall rules, or an endpoint that is stopped or misconfigured on SQL Server 2025. It can also result from insufficient permissions on the mirroring endpoint (missing CONNECT rights), expired or mismatched certificates used for endpoint authentication, or corruption in the mirroring session state after an unexpected failover. In some cases, this error surfaces because the SQL Server service account lacks proper network access or the TCP port assigned to mirroring is already in use by another process.

Step-by-Step Resolution Guide

Step 1: Verify the Database Mirroring Endpoint Status

  • Run the following query to check endpoint state:
  SELECT name, state_desc, port, encryption_algorithm_desc 
  FROM sys.database_mirroring_endpoints;
  • If state_desc shows STOPPED, restart it manually:
  ALTER ENDPOINT [Mirroring] STATE = STARTED;
  • Confirm no other application is bound to the same port using:
  netstat -ano | findstr <port_number>

Step 2: Check Firewall and Network Configuration

  • On Windows Server 2025 / Windows 11, open Windows Defender Firewall with Advanced Security.
  • Create or verify an inbound rule allowing TCP traffic on the mirroring port (default 5022):
  New-NetFirewallRule -DisplayName "SQL Mirroring" -Direction Inbound -Protocol TCP -LocalPort 5022 -Action Allow
  • Ensure both the principal and mirror servers can reach each other over this port using Test-NetConnection -ComputerName <PartnerServer> -Port 5022.

Step 3: Validate Permissions and Certificates

  • Confirm the SQL Server service account has CONNECT permission on the endpoint:
  GRANT CONNECT ON ENDPOINT::[Mirroring] TO [DOMAIN\SQLServiceAccount];
  • If using certificate-based authentication, check certificate expiration:
  SELECT name, expiry_date FROM sys.certificates;
  • Reissue and re-bind certificates on both the principal and mirror instances if expired or mismatched.

Step 4: Restart the Mirroring Session

  • Pause and resume mirroring via SQL Server Management Studio (SSMS) or T-SQL:
  ALTER DATABASE [YourDB] SET PARTNER SUSPEND;
  ALTER DATABASE [YourDB] SET PARTNER RESUME;
  • Monitor the SQL Server error log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for confirmation that the mirroring thread started successfully.

Alternative or Verification Steps

  • Re-run SELECT * FROM sys.dm_db_mirroring_connections; to confirm an active connection between principal and mirror with no errors.
  • If the issue persists, drop and recreate the mirroring endpoint entirely using DROP ENDPOINT [Mirroring]; followed by a fresh CREATE ENDPOINT statement with correct port and certificate bindings.

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

Troubleshooting Guide: SQL Server Error 1232 – “Failed to Acquire Lock with Lock Manager Service”

Why This Error Happens

This error typically occurs when the SQL Server Lock Manager is unable to obtain or communicate lock resources, often due to the SQL Server Service Account lacking the necessary permissions on the resource database or lock-related registry keys. It can also stem from a conflict with another process (such as a second SQL instance or a security tool) holding exclusive access to the required memory-mapped lock structures. In some cases, this is triggered by corrupted system files within the Binn directory or an improperly configured tempdb that cannot allocate the lock manager’s internal memory partitions.

Step-by-Step Resolution Guide

Step 1: Verify Service Account Permissions

  • Open Services.msc and locate the SQL Server (MSSQLSERVER) service.
  • Right-click and select Properties to view the Log On As account.
  • Ensure this account has Full Control on the SQL Server installation directory (e.g., C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA).
  • Grant the account “Log on as a service” rights via secpol.msc > Local Policies > User Rights Assignment.

Step 2: Check for Port and Resource Conflicts

  • Open Command Prompt as Administrator and run netstat -ano | findstr 1433 to check if the default SQL port is being hijacked by another process.
  • Verify no other SQL instances or third-party backup/AV tools are locking the .mdf or .ldf files in the data directory.
  • Use Resource Monitor (resmon.exe) to check the “CPU” tab for handles associated with sqlservr.exe to identify blocking processes.

Step 3: Rebuild the Lock Manager via tempdb Reconfiguration

  • Open SQL Server Configuration Manager.
  • Navigate to the Startup Parameters tab for the SQL Server instance.
  • Temporarily add the parameter -T3609 to force a clean rebuild of tempdb on the next restart, which often resolves corrupted lock manager memory partitions.
  • Restart the SQL Server service via net stop MSSQLSERVER followed by net start MSSQLSERVER.

Step 4: Repair Corrupted Binaries

  • Run the SQL Server 2025 Installation Media and select Repair under Maintenance options.
  • Allow the wizard to scan and replace any corrupted files in the Binn folder that might be causing the Lock Manager service to crash on initialization.
  • Reboot the Windows Server 2025 machine after the repair completes.

Alternative or Verification Steps

  • Verify the Fix: Open SQL Server Management Studio (SSMS) and run SELECT * FROM sys.dm_tran_locks; to confirm that lock requests are being granted and queued correctly without immediate failure.
  • Alternative Solution: If the error persists, detach the affected database, rename the .mdf/.ldf files, and re-attach them using CREATE DATABASE... FOR ATTACH to bypass a potentially corrupted lock manager pointer associated with that specific database file.

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

Troubleshooting Guide: Error 1231 – Blocked Process/Deadlock Report Generation Failure

Why This Error Happens

Error 1231 occurs when SQL Server’s internal monitoring mechanism detects a blocked process or deadlock condition but cannot allocate the resources necessary to build the XML report describing it. This is typically caused by severe memory pressure in the internal resource pool, a corrupted or inaccessible system health session (used by Extended Events), or insufficient permissions on the SQL Server service account to write diagnostic output. In some cases, this also surfaces when the blocked process threshold configuration is set too aggressively low, causing the reporting subsystem to be overwhelmed by report requests before it can process them.

Step-by-Step Resolution Guide

Step 1: Verify and Adjust the Blocked Process Threshold

  • Open SQL Server Management Studio (SSMS) and connect via a Dedicated Administrator Connection (DAC) if the instance is unresponsive.
  • Run EXEC sp_configure 'show advanced options', 1; RECONFIGURE; followed by EXEC sp_configure 'blocked process threshold (s)';
  • If the value is set below 5 seconds, increase it using EXEC sp_configure 'blocked process threshold (s)', 15; RECONFIGURE; to reduce report generation frequency and resource strain.

Step 2: Check and Repair the System Health Extended Events Session

  • Navigate to Management > Extended Events > Sessions in SSMS and confirm the system_health session is running.
  • Run SELECT * FROM sys.dm_xe_sessions WHERE name = 'system_health'; to confirm it is active and not suspended.
  • If the session is stopped or corrupted, restart it manually with ALTER EVENT SESSION system_health ON SERVER STATE = START;
  • Check the session’s target file path (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) for disk space or permission issues.

Step 3: Validate Memory Pressure on the Instance

  • Query SELECT total_physical_memory_kb, available_physical_memory_kb FROM sys.dm_os_sys_memory; to check for low available memory.
  • If memory pressure is confirmed, review the max server memory (MB) setting under Server Properties > Memory in SSMS and ensure it is not configured too close to total physical RAM, leaving at least 2–4 GB for the OS.
  • Restart the SQL Server service via Services.msc or net stop MSSQLSERVER && net start MSSQLSERVER if memory settings were adjusted.

Step 4: Confirm Service Account Permissions

  • Open Services.msc on Windows Server 2025 / Windows 11, locate the SQL Server (MSSQLSERVER) service, and check the Log On tab for the account in use.
  • Ensure this account has full read/write permissions on the SQL Server log directory and the Extended Events target file directory.
  • Use icacls “C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log” /grant “NT SERVICE\MSSQLSERVER”:(OI)(CI)F to reapply correct permissions if needed.

Alternative or Verification Steps

  • After applying changes, reproduce a test blocking scenario and query SELECT * FROM sys.fn_xe_file_target_read_file('system_health*.xel', NULL, NULL, NULL); to confirm reports now generate correctly without Error 1231 appearing in the SQL Server Error Log.
  • As an alternative, if the issue persists, create a dedicated custom Extended Events session targeting blocked_process_report and xml_deadlock_report events with a ring_buffer target instead of relying solely on system_health, which isolates the reporting mechanism from other system diagnostic overhead.

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

Troubleshooting Guide: SQL Server Error 1230 – “Invalid Database Principal”

Why This Error Happens

Error 1230 occurs when a Transact-SQL statement references a database principal (such as a user, role, or schema) that does not exist, is malformed, or has become orphaned from its corresponding server-level login. This commonly happens after a database restore or migration where the Security Identifier (SID) of the login no longer matches the SID mapped to the user inside the database. It can also occur if a principal was dropped but is still referenced in ownership chains, permissions scripts, or stored procedures.

Step-by-Step Resolution Guide

Step 1: Identify the Orphaned or Invalid Principal

  • Open SQL Server Management Studio (SSMS) and connect to the instance running on Windows Server 2025.
  • Run the following query to check for orphaned users: EXEC sp_change_users_login 'Report';
  • Note the specific UserName returned, as this is likely the invalid principal referenced in Error 1230.

Step 2: Verify the Principal Exists in sys.database_principals

  • Query the system view to confirm the principal’s status: SELECT * FROM sys.database_principals WHERE name = 'YourPrincipalName';
  • If the query returns zero rows, the principal has been dropped or was never successfully created, confirming it is invalid for the operation being attempted.
  • Cross-reference this with sys.server_principals to check for SID mismatches between the server login and the database user.

Step 3: Re-map the SID or Re-create the User

  • If the SID is mismatched (common after a database restore), re-link the user to the correct login using: ALTER USER YourUsername WITH LOGIN = YourServerLoginName;
  • If the principal was deleted entirely but is required by a dependent object (like a Stored Procedure owner), re-create it: CREATE USER YourUsername FOR LOGIN YourServerLoginName;
  • Ensure you are executing these commands within the context of the specific database (USE YourDatabaseName;) where the error is occurring, not the master database.

Step 4: Update Ownership Chains and Permissions

  • If the error occurs during an ALTER AUTHORIZATION or GRANT statement, verify the syntax is pointing to a valid, existing principal name.
  • Re-apply necessary permissions to the newly fixed principal: GRANT SELECT, INSERT, UPDATE ON dbo.YourTable TO YourUsername;
  • Restart the SQL Server service via the Windows Server 2025 Services console (services.msc) if permissions changes do not reflect immediately in active sessions.

Alternative or Verification Steps

  • Verification: Re-run the original query or application process that threw Error 1230. If successful, check the SQL Server Error Log (via SSMS > Management > SQL Server Logs) to confirm no further principal-related warnings appear.
  • Alternative: If sp_change_users_login fails to repair the mapping, manually drop the orphaned database user (DROP USER YourUsername;) and recreate it fresh using CREATE USER... FOR LOGIN... to force a clean SID synchronization.

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

Why This Error Happens

Error 1228 occurs when the sp_getapplock, sp_releaselock, or sp_releaseapplock system stored procedures receive a parameter value that falls outside the set of values SQL Server’s Lock Manager recognizes as valid. This is typically caused by a misconfigured @LockMode (must be Shared, Update, Exclusive, IntentShared, or IntentExclusive), an invalid @LockOwner (must be Transaction or Session), or a @Resource string that exceeds the 255-character limit. It is a code-level/application-logic issue rather than a server configuration fault, often surfacing after an application update, a custom T-SQL script change, or an ORM-generated query that passes dynamic or null values into these procedures.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Call

  • Open SQL Server Management Studio (SSMS) and enable SQL Server Profiler or Extended Events to capture the exact statement triggering Error 1228.
  • Filter the trace on Error Number = 1228 and capture the TextData column to see the exact parameter values passed.
  • Cross-reference the captured call with your application’s connection string and the calling stored procedure or application code module.

Step 2: Validate Parameter Values Against Allowed Enumerations

  • Confirm @LockMode is exactly one of: Shared, Update, Exclusive, IntentShared, IntentExclusive (case-sensitive string match is required).
  • Confirm @LockOwner is set to either Transaction or Session — not Session_Transaction or a custom string.
  • Check that @Resource is a nvarchar(255) or shorter and does not contain unescaped special characters or NULL values passed unintentionally from application-layer code (common in .NET DbParameter objects where a default value wasn’t set).

Step 3: Patch or Correct the Application/Script Logic

  • In Windows Server 2025, open C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ and review the ERRORLOG file for the full stack trace tied to the 1228 event.
  • Update the calling script or stored procedure to hardcode or validate the enumeration values before passing them, e.g., wrap the call in an IF check:
IF @LockMode NOT IN ('Shared','Update','Exclusive','IntentShared','IntentExclusive')
    THROW 50000, 'Invalid LockMode specified', 1;
  • If using an ORM (Entity Framework, Dapper), inspect the generated SQL via SQL Profiler to ensure parameter mapping hasn’t defaulted to NULL or an incorrect type.

Step 4: Apply SQL Server 2025 Cumulative Update

  • Verify you are on the latest Cumulative Update (CU) via SELECT @@VERSION; in SSMS.
  • Download and install the latest CU from the Microsoft Update Catalog if a known bug exists in sp_getapplock parameter validation for your build.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER after patching.

Alternative or Verification Steps

  • Re-run the original transaction or application workflow and confirm Error 1228 no longer appears in the ERRORLOG or Profiler trace.
  • As an alternative, isolate the application lock call in a standalone test script in SSMS with known-good static values (e.g., EXEC sp_getapplock @Resource='TestLock', @LockMode='Exclusive';) to confirm the lock function itself works, proving the issue was parameter-side rather than server-side.

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

Troubleshooting Guide: SQL Server Error 1227 – Invalid Application Lock Time-out

Why This Error Happens

This error occurs when the @LockTimeout parameter passed to the sp_getapplock stored procedure contains an invalid value, typically a negative number less than -1 or a value exceeding the acceptable integer range. It commonly results from application code dynamically calculating a timeout value (such as from a configuration file or environment variable) that resolves to NULL, a negative integer, or a non-numeric string due to a coding defect or corrupted configuration entry. This can also surface after a migration to SQL Server 2025 if legacy T-SQL scripts used implicit conversions that are no longer tolerated by the updated Database Engine.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Procedure

  • Check the SQL Server Error Log via SQL Server Management Studio (SSMS) or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG on Windows Server 2025 to find the exact timestamp of the failure.
  • Use SQL Server Profiler or Extended Events to capture the exact sp_getapplock call and the parameter value being passed at the time of failure.
  • Correlate the Event ID 1227 in the Windows Event Viewer (Application Logs) with the corresponding application transaction ID.

Step 2: Validate and Correct the Application Code

  • Open the source code or stored procedure where sp_getapplock is called and locate the @LockTimeout variable.
  • Ensure the value is explicitly cast as an INT and falls within the valid range (-1 for infinite wait, or 0 and higher for milliseconds).
  • Replace any dynamic variable injection with a hardcoded test value (e.g., @LockTimeout = 5000) to confirm the fix resolves the error.
  • If using an ORM (like Entity Framework) or a .NET connection string, check the CommandTimeout settings to ensure they aren’t passing a malformed value to the stored procedure.

Step 3: Check for Configuration File Corruption

  • If the timeout value is being pulled from an external appsettings.json or web.config file, verify the specific key-value pair is not missing or malformed.
  • Navigate to the application’s root directory (e.g., C:\inetpub\wwwroot\YourApp\appsettings.json) and ensure the LockTimeoutSettings key contains a valid integer string.
  • Restart the IIS Application Pool or Windows Service associated with the app to ensure the corrected configuration is loaded into memory.

Step 4: Apply SQL Server 2025 Compatibility Fixes

  • Verify the database compatibility level is set correctly for SQL Server 2025 by running SELECT compatibility_level FROM sys.databases WHERE name = 'YourDBName';.
  • If the compatibility level is outdated, update it using ALTER DATABASE YourDBName SET COMPATIBILITY_LEVEL = 170; to ensure proper handling of the sp_getapplock parameter types.

Alternative or Verification Steps

  • To verify the fix, execute the corrected stored procedure manually in SSMS using a known safe value (e.g., EXEC sp_getapplock @Resource = 'TestLock', @LockMode = 'Exclusive', @LockTimeout = 1000;) and confirm it returns a status of 0 or 1 without throwing Error 1227.
  • If the error persists despite code correction, use SQL Server Management Studio’s “Query Store” feature to check if a cached execution plan is forcing an invalid parameter sniffing value, and clear the cache using DBCC FREEPROCCACHE as a temporary workaround.

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

Troubleshooting Guide: Error 1226 – Invalid Application Lock Owner

Why This Error Happens

Error 1226 occurs when the sp_getapplock or sp_releaseapplock stored procedures are called with an @LockOwner parameter value that doesn’t match the actual transactional or session context in which the lock was originally acquired. This typically happens when application code mixes Transaction and Session owner modes incorrectly, or attempts to release a lock from a different session/connection than the one that created it. Connection pooling issues and improperly scoped SqlConnection objects in application code are the most common underlying causes.

Step-by-Step Resolution Guide

Step 1: Identify the Lock Owner Mismatch in Application Code

  • Review all calls to sp_getapplock and sp_releaseapplock in your stored procedures or application data access layer.
  • Confirm whether @LockOwner is set to 'Transaction' or 'Session' consistently across the acquire and release calls.
  • Search your codebase (C#, .NET, or T-SQL scripts) for mismatched owner parameters, e.g.:
EXEC sp_getapplock @Resource = 'MyLock', @LockMode = 'Exclusive', @LockOwner = 'Session';
EXEC sp_releaseapplock @Resource = 'MyLock', @LockOwner = 'Transaction'; -- Mismatch here

Step 2: Standardize Lock Owner Mode Across the Application

  • If using @LockOwner = 'Transaction', ensure the lock is acquired and released within the same explicit transaction (BEGIN TRAN / COMMIT/ROLLBACK).
  • If using @LockOwner = 'Session', ensure the same physical connection (SPID) that acquired the lock is the one releasing it — do not rely on connection pooling to guarantee this.
  • Update connection string settings in app.config or web.config to disable pooling for this specific lock-dependent connection if session-scoped locks are required:
Pooling=false;

Step 3: Validate Session Context Using DMVs

  • Open SQL Server Management Studio (SSMS) on your Windows Server 2025 instance and run:
SELECT resource_description, request_owner_type, request_session_id 
FROM sys.dm_tran_locks 
WHERE resource_type = 'APPLICATION';
  • Confirm the request_owner_type matches what your application expects (SESSION vs TRANSACTION).
  • Cross-reference request_session_id with @@SPID in your active query window to confirm you’re operating in the correct session.

Step 4: Patch and Restart SQL Server Services

  • Apply the latest Cumulative Update (CU) for SQL Server 2025 via Windows Update or the SQL Server Installation Center, as this error has known fixes in recent builds.
  • Restart the SQL Server service via services.msc or PowerShell:
Restart-Service -Name 'MSSQLSERVER' -Force

Alternative or Verification Steps

  • Verify the fix by running a load test that repeatedly acquires and releases the application lock under concurrent sessions; monitor the SQL Server Error Log (ERRORLOG) for recurrence of Error 1226.
  • As an alternative, replace sp_getapplock/sp_releaseapplock logic with native transaction isolation levels (e.g., SERIALIZABLE) or sys.sp_getapplock wrapped in a retry-safe TRY...CATCH block to avoid owner-type ambiguity entirely.

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

Why This Error Happens

Error 1225 occurs when the sp_getapplock or sp_releaseapplock stored procedures receive an invalid value for the @LockMode parameter, meaning the value passed does not match one of the accepted modes (Shared, Update, Exclusive, IntentShared, IntentExclusive). This is typically caused by a coding defect in application logic, a corrupted or mismatched parameter value passed through dynamic SQL, or an outdated application binary that references deprecated lock mode strings. It can also surface after an upgrade to SQL Server 2025 if legacy stored procedures were compiled against an older system procedure signature.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Procedure

  • Open SQL Server Management Studio (SSMS) and enable SQL Profiler or Extended Events to capture the exact statement raising Error 1225.
  • Look specifically for calls to sp_getapplock or sp_releaseapplock in the captured trace.
  • Note the exact string passed as @LockMode (e.g., check for typos like "Exclusiv" instead of "Exclusive").

Step 2: Validate the Lock Mode Parameter in Code

  • Open the application source code or stored procedure definition referencing the applock call.
  • Confirm the @LockMode value matches one of the five valid strings exactly (case-insensitive but spelling-sensitive): Shared, Update, Exclusive, IntentShared, IntentExclusive.
  • Update any hardcoded or dynamically built strings to match these exact values.
  • Example fix:
  EXEC sp_getapplock @Resource = 'MyResource', 
                      @LockMode = 'Exclusive', 
                      @LockOwner = 'Session', 
                      @LockTimeout = 5000;

Step 3: Recompile and Refresh Dependent Objects

  • Run sp_recompile 'YourProcedureName' in SSMS to clear any cached, outdated execution plans.
  • If using an ORM (Entity Framework, Dapper, etc.), confirm the mapped stored procedure parameters have not drifted from the updated SQL definition.
  • Restart the application service or connection pool to ensure no stale cached metadata is reused.

Step 4: Check for SQL Server 2025 Compatibility Changes

  • Review the Database Engine compatibility level (sys.databases.compatibility_level) to ensure it is set to the correct level for SQL Server 2025 (160 or higher).
  • Run:
  ALTER DATABASE YourDatabase SET COMPATIBILITY_LEVEL = 160;
  • Confirm no legacy applock wrapper functions override the system procedure with outdated parameter validation logic.

Alternative or Verification Steps

  • Re-run the previously failing transaction or stored procedure and confirm Error 1225 no longer appears in the SQL Server error log (Logs folder under MSSQL\Log) or Windows Event Viewer.
  • If the error persists, isolate the issue by manually executing sp_getapplock with each valid lock mode value in a test query window to confirm the procedure itself is functioning correctly, then trace back through the application call stack to find where the invalid value is being generated.

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

Troubleshooting Guide: SQL Server Error 1224 — Invalid Application Lock Resource

Why This Error Happens

This error occurs when the sp_getapplock, sp_releaseapplock, or APPLOCK_TEST system procedures/functions receive a resource name that is either NULL, empty, or exceeds the 255-character limit allowed for application lock resource identifiers. It commonly happens when application code dynamically constructs lock resource names (e.g., by concatenating GUIDs, timestamps, or long string keys) without validating length or null-checking the input first. In rarer cases, this can also surface due to corrupted metadata in tempdb where application locks are tracked, requiring a service-level restart to clear transient state.

Step-by-Step Resolution Guide

Step 1: Audit the Application Lock Resource Name in Code

  • Locate the T-SQL block or stored procedure calling sp_getapplock @Resource = ....
  • Confirm the @Resource parameter is not NULL or an empty string ('').
  • Verify the string length does not exceed 255 characters using LEN(@Resource) before the call.
  • If using dynamically generated keys (e.g., CONCAT(@TableName, @UserID, @SessionGUID)), add a TRUNCATE or hash (e.g., HASHBYTES('SHA2_256', @Resource)) to keep it within bounds.

Step 2: Validate Input Parameters Before Execution

  • Wrap the lock call in a validation block:
  IF @Resource IS NULL OR LEN(@Resource) = 0 OR LEN(@Resource) > 255
      THROW 50000, 'Invalid lock resource name supplied.', 1;
  • Check any ORM frameworks (Entity Framework, Dapper) or middleware that auto-generates lock names—update the mapping logic to sanitize strings.
  • Review connection pooling settings in Windows Server 2025 IIS or your app’s connection string to ensure no stale sessions are passing cached null parameters.

Step 3: Clear Transient Tempdb State and Restart Services

  • Open SQL Server Configuration Manager on Windows Server 2025 / Windows 11.
  • Restart the SQL Server (MSSQLSERVER) service to flush any corrupted application lock tracking in tempdb.
  • If the issue persists, manually shrink and recreate tempdb via:
  USE master;
  ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 512MB);
  • Re-run the failing transaction to confirm the lock resource is now processed correctly.

Step 4: Patch and Update SQL Server 2025

  • Check for cumulative updates via SQL Server Management Studio (SSMS) → Help → Check for Updates.
  • Apply the latest Cumulative Update (CU) for SQL Server 2025, as this error has known edge-case fixes in service parameter validation.
  • Restart the SQL Server service after patching to apply changes.

Alternative or Verification Steps

  • Run a test transaction using a known-good, short resource name (e.g., EXEC sp_getapplock @Resource = 'TestLock1', @LockMode = 'Exclusive';) to confirm the procedure executes without Error 1224.
  • If the error persists after code validation, enable SQL Server Extended Events with the error_reported event filtered on Error 1224 to capture the exact malformed resource string being passed at runtime for deeper root-cause analysis.

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

Troubleshooting Guide: SQL Server Error 1223 — “Cannot Release the Application Lock”

Why This Error Happens

Error 1223 occurs when a session attempts to release an application lock (via sp_releaseapplock) that it does not currently own, or that was never successfully acquired in that scope (transaction or session). This commonly happens due to a mismatch between the @LockOwner parameter used in sp_getapplock versus sp_releaseapplock, or because the owning transaction already committed/rolled back, implicitly releasing the lock. It can also surface when the calling principal lacks sufficient permission on the lock resource, causing the engine to reject the release request for that Database Principal.

Step-by-Step Resolution Guide

Step 1: Verify Lock Owner Consistency

  • Check your application or stored procedure code for mismatched @LockOwner values between sp_getapplock and sp_releaseapplock calls.
  • Ensure both calls use the same scope — either 'Transaction' or 'Session' — consistently.
  • Example correct pairing:
  EXEC sp_getapplock @Resource = 'MyLock', @LockMode = 'Exclusive', @LockOwner = 'Session';
  -- work here
  EXEC sp_releaseapplock @Resource = 'MyLock', @LockOwner = 'Session';

Step 2: Inspect Active Sessions and Lock State

  • Open SQL Server Management Studio (SSMS) connected to the Windows Server 2025 instance.
  • Run the following query to inspect current application locks:
  SELECT request_session_id, resource_description, request_mode, request_status
  FROM sys.dm_tran_locks
  WHERE resource_type = 'APPLICATION';
  • Confirm whether the lock was already released due to an implicit transaction commit/rollback before your release call executed.

Step 3: Validate Database Principal Permissions

  • Confirm the login/user referenced in the error message has EXECUTE permission on sp_getapplock and sp_releaseapplock.
  • In SSMS, navigate to Security > Logins > [Login Name] > User Mapping and verify the database role membership (e.g., db_datareader, db_owner, or a custom role with explicit EXECUTE grants).
  • Grant missing permissions if needed:
  GRANT EXECUTE ON sp_getapplock TO [DatabasePrincipalName];
  GRANT EXECUTE ON sp_releaseapplock TO [DatabasePrincipalName];

Step 4: Review Transaction Boundaries in Application Code

  • Ensure the application does not call sp_releaseapplock after the transaction has already auto-committed or timed out.
  • Wrap lock acquisition and release within a single, well-defined BEGIN TRAN ... COMMIT/ROLLBACK block to avoid orphaned release calls.
  • Add error handling (TRY...CATCH) so release calls are skipped if the lock was never successfully acquired.

Alternative or Verification Steps

  • Re-run the stored procedure or application workflow and confirm no Error 1223 appears in the SQL Server Error Log (Windows Server 2025 path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • If the issue persists, use Extended Events (sqlserver.error_reported) to capture the exact session and transaction context at the moment of failure for deeper diagnosis.

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

Troubleshooting Guide: SQL Server Error 1222 – “Lock Request Time Out Period Exceeded”

Why This Error Happens

This error occurs when a transaction attempts to acquire a lock on a resource (table, row, or page) that is already held by another session for longer than the configured LOCK_TIMEOUT duration. It is typically caused by a long-running blocking transaction, an uncommitted transaction left open by an application, or excessive lock escalation due to poor query design. In SQL Server 2025 running on Windows Server 2025 or Windows 11, this is often exacerbated by outdated statistics or missing indexes that force broader lock scopes than necessary.

Step-by-Step Resolution Guide

Step 1: Identify the Blocking Session

  • Open SQL Server Management Studio (SSMS) and run sp_who2 or query sys.dm_exec_requests to find the blocking_session_id.
  • Use the command: SELECT * FROM sys.dm_tran_locks WHERE request_status = 'WAIT'; to pinpoint the exact resource being contested.
  • Cross-reference the session_id with sys.dm_exec_sql_text to view the actual query causing the block.

Step 2: Terminate or Optimize the Offending Transaction

  • If the blocking session is a runaway or orphaned transaction, terminate it using KILL [session_id];.
  • Review the application code (e.g., .NET or Java connectors) for missing COMMIT or ROLLBACK statements that leave transactions open indefinitely.
  • Ensure the application is not using SERIALIZABLE isolation level unnecessarily, as this increases lock duration significantly.

Step 3: Adjust Lock Timeout and Indexing Strategy

  • Temporarily increase the lock timeout threshold for specific sessions using SET LOCK_TIMEOUT 5000; (value in milliseconds) to allow more time for transactions to clear naturally.
  • Navigate to the specific table via SSMS Object Explorer and check for missing indexes using the “Missing Index” suggestions in the Execution Plan.
  • Run ALTER INDEX ALL ON [TableName] REORGANIZE; to reduce the need for table-level locks caused by fragmentation.

Step 4: Enable Read Committed Snapshot Isolation (RCSI)

  • Reduce blocking contention by enabling RCSI, which uses row versioning instead of locks for read operations.
  • Execute the following in a query window: ALTER DATABASE [YourDatabaseName] SET READ_COMMITTED_SNAPSHOT ON;
  • Note: Ensure no active connections are present in the database before running this command, as it requires exclusive access momentarily.

Alternative or Verification Steps

  • Verification: Re-run the failing transaction/query via SSMS; if Error 1222 does not reappear and the query completes within the standard timeout window, the blocking issue is resolved.
  • Alternative: If blocking persists across the cluster, check Windows Server 2025 Resource Monitor for disk I/O bottlenecks, as slow disk read/write speeds can artificially extend transaction lock times, triggering the timeout even without application-level errors.

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

Troubleshooting Guide: SQL Server Error 1221 — “Database Engine is attempting to release a group of locks that are not currently held by the transaction”

Why This Error Happens

This error typically occurs due to internal lock manager inconsistencies, often triggered by deadlock resolution conflicts, corrupted lock structures in memory, or a transaction attempting to release locks that were already released by a prior rollback operation. It can also surface when third-party backup tools, antivirus software, or filter drivers interfere with SQL Server’s I/O operations, causing transaction state mismatches. In rare cases, this is a symptom of underlying database corruption or outdated SQL Server build-level bugs related to lock escalation logic.

Step-by-Step Resolution Guide

Step 1: Apply the Latest SQL Server 2025 Cumulative Update

  • Navigate to Microsoft’s official download center and check the current Cumulative Update (CU) level for SQL Server 2025.
  • Run SELECT @@VERSION; in SSMS to confirm your current build number.
  • Install the latest CU, as lock manager bugs are frequently patched in servicing releases.
  • Reboot the server after installation: Restart-Computer -Force (via PowerShell as Administrator).

Step 2: Check for Antivirus or Filter Driver Interference

  • Open Windows Security or your third-party AV console and add exclusions for SQL Server data/log directories (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA).
  • Exclude the sqlservr.exe process from real-time scanning.
  • Use fltmc.exe in an elevated Command Prompt to list active filter drivers and identify any non-Microsoft drivers attached to the volume hosting your database files.
  • Temporarily disable third-party backup agents (e.g., VSS-based tools) to rule out I/O conflicts.

Step 3: Run DBCC CHECKDB to Rule Out Corruption

  • Execute DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; in SSMS.
  • Review the output for allocation or consistency errors tied to the affected tables or indexes.
  • If corruption is found, restore from the most recent clean backup or use DBCC CHECKDB('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) only as a last resort in a maintenance window.

Step 4: Review and Adjust Lock Escalation Settings

  • Query current lock escalation behavior: SELECT name, value FROM sys.configurations WHERE name = 'locks';
  • If the server has a fixed, low locks configuration value, reset it to dynamic allocation: EXEC sp_configure 'locks', 0; RECONFIGURE;
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER -Force for the change to take effect.

Step 5: Enable Trace Flags for Deeper Diagnostics

  • Add Trace Flag 1211 or 1224 (lock escalation control) temporarily in SQL Server Configuration Manager under Startup Parameters (e.g., -T1211).
  • Capture a SQL Server Profiler or Extended Events trace filtered on Error 1221 to identify the exact query/transaction triggering the issue.
  • Remove the trace flag once root cause is identified, as it can impact performance long-term.

Alternative or Verification Steps

  • Re-run the previously failing transaction/workload under a monitored session and confirm Error 1221 no longer appears in the SQL Server Error Log (EXEC sp_readerrorlog;).
  • If the issue persists after patching and corruption checks, open a Microsoft Support (CSS) case and provide a SQL Server memory dump generated at the time of failure for deep lock-manager analysis.

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

Troubleshooting Guide: SQL Server Error 1220 – “No More Lock Classes Available”

Why This Error Happens

Error 1220 occurs when a single transaction exhausts the internal lock owner blocks (lock classes) that SQL Server allocates to track locks within that transaction’s scope. This typically happens when a transaction performs an extremely high number of operations (bulk inserts, updates, or deletes) without intermediate commits, causing the internal lock management structures to overflow. It can also surface when the server is under severe memory pressure, limiting the resources available for the Lock Manager to allocate new lock classes dynamically.

Step-by-Step Resolution Guide

Step 1: Break Up the Large Transaction

  • Identify the query or stored procedure reported in the error (check SQL Server Error Log or Extended Events for the associated Session ID).
  • Refactor large batch operations (e.g., DELETE, UPDATE, INSERT) into smaller chunks using a loop with TOP (n) and explicit COMMIT statements.
  • Example pattern:
  WHILE 1 = 1
  BEGIN
      DELETE TOP (10000) FROM LargeTable WHERE Condition = 1;
      IF @@ROWCOUNT = 0 BREAK;
  END

Step 2: Review and Increase the ‘locks’ Configuration Option

  • Although SQL Server dynamically manages locks by default, verify the locks server configuration hasn’t been manually capped.
  • Run the following in SSMS to check current settings:
  EXEC sp_configure 'show advanced options', 1;
  RECONFIGURE;
  EXEC sp_configure 'locks';
  • If the value is non-zero (indicating a fixed limit), reset it to 0 to allow dynamic allocation:
  EXEC sp_configure 'locks', 0;
  RECONFIGURE;
  • Restart the SQL Server service via services.msc or Computer Management on Windows Server 2025/Windows 11 for the change to take effect.

Step 3: Check System Memory Allocation

  • Navigate to Task Manager > Performance > Memory to ensure the OS isn’t starving SQL Server of RAM.
  • In SSMS, verify the max server memory setting isn’t too restrictive relative to the physical hardware:
  EXEC sp_configure 'max server memory (MB)';
  • Increase the allocated memory if the server has available physical RAM headroom, then apply via RECONFIGURE.

Step 4: Apply Latest Cumulative Updates

  • Navigate to the Microsoft Update Catalog or use Windows Update settings to ensure Windows Server 2025 is fully patched.
  • Download and install the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Download Center to ensure known Lock Manager bugs are patched.
  • Reboot the server post-installation to finalize the patch application.

Alternative or Verification Steps

  • Verification: Re-run the previously failing transaction/batch job and monitor sys.dm_tran_locks in a separate query window to confirm lock counts remain stable and do not spike uncontrollably.
  • Alternative: If chunking the transaction is not feasible immediately, temporarily isolate the workload to a session with SET DEADLOCK_PRIORITY LOW and monitor via Performance Monitor (PerfMon) using the SQLServer:Locks counter to catch the threshold before it errors out again.

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

Troubleshooting Guide: SQL Server Error 1219 – Session Disconnected Due to High Priority DDL Operation

Why This Error Happens

This error occurs when a Data Definition Language (DDL) operation, such as an online index rebuild or a schema change, requires a Schema Modification (Sch-M) lock that conflicts with active user sessions. SQL Server 2025 prioritizes the DDL operation and forcibly disconnects lower-priority sessions holding conflicting locks to prevent indefinite blocking. This is often triggered by WAIT_AT_LOW_PRIORITY settings being misconfigured or absent during online maintenance operations on tables with high concurrent read/write activity.

Step-by-Step Resolution Guide

Step 1: Identify the Conflicting DDL Operation

  • Open SQL Server Management Studio (SSMS) and query the DMV to find active DDL operations:
  • Run: SELECT * FROM sys.dm_exec_requests WHERE command LIKE '%ALTER%' OR command LIKE '%CREATE INDEX%';
  • Check the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\LOG\ERRORLOG for the exact timestamp and object involved.
  • Note the session_id and blocking_session_id values to understand the lock chain.

Step 2: Reconfigure the Index/DDL Operation with Low Priority Wait

  • Modify the DDL script to use the WAIT_AT_LOW_PRIORITY option instead of forcing an immediate schema lock.
  • Example syntax for an index rebuild:
ALTER INDEX [YourIndexName] ON [dbo].[YourTable]
REBUILD WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 5 MINUTES, ABORT_AFTER_WAIT = SELF)));
  • Setting ABORT_AFTER_WAIT = SELF ensures the DDL operation cancels itself rather than killing active user sessions.

Step 3: Adjust Application Connection Retry Logic

  • Navigate to your application’s connection string configuration file (e.g., web.config or appsettings.json).
  • Implement retry logic to handle transient disconnections gracefully:
  • Set ConnectRetryCount=3 and ConnectRetryInterval=10 in the connection string for SQL Server 2025 compatible drivers.
  • Ensure the application driver supports “Idle Connection Resiliency” to avoid full session termination errors.

Step 4: Schedule DDL Operations During Low-Traffic Windows

  • Open SQL Server Agent in SSMS.
  • Create a new Job under SQL Server Agent > Jobs > New Job.
  • Schedule the high-priority DDL script (identified in Step 1) to run during off-peak hours (e.g., 2:00 AM – 4:00 AM) to minimize active session conflicts.

Alternative or Verification Steps

  • Verification: Re-run the DDL operation during a monitored window and check sys.dm_exec_requests to confirm no sessions are being forcibly terminated with wait_type = 'LCK_M_SCH_M'.
  • Alternative: If the issue persists on critical production tables, consider using Resumable Online Index Rebuilds (a native SQL Server 2025 feature), which allows you to pause and resume the DDL operation instead of forcing a disconnect via ALTER INDEX ... RESUME.

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

Troubleshooting Guide: Error 1218 – ABORTAFTERWAIT = BLOCKERS Lock Request

Why This Error Happens

This error occurs when a session uses the ABORT_AFTER_WAIT = BLOCKERS lock option within a high-priority transaction, and SQL Server deliberately terminates lower-priority blocking sessions to allow the high-priority request to proceed. It is typically triggered during online index rebuild operations (ONLINE = ON) or DDL operations that use low-priority wait semantics to avoid long blocking chains. The root cause is usually a long-running transaction or an uncommitted session holding a schema lock (Sch-M or Sch-S) on the target table while the online operation attempts to acquire a conflicting lock within its configured wait threshold.

Step-by-Step Resolution Guide

Step 1: Identify the Blocking Session

  • Query sys.dm_tran_locks and sys.dm_exec_requests to find sessions holding Sch-S or Sch-M locks on the affected database_id.
  • Run: SELECT request_session_id, resource_type, request_mode, resource_database_id FROM sys.dm_tran_locks WHERE request_status = 'GRANT';
  • Cross-reference the blocking session_id with sys.dm_exec_sql_text to identify the offending query.

Step 2: Review the Low-Priority Lock Wait Configuration

  • Check the original DDL/index statement for the WAIT_AT_LOW_PRIORITY clause.
  • Verify the configured MAX_DURATION and ABORT_AFTER_WAIT settings:
  • MAX_DURATION = X MINUTES
  • ABORT_AFTER_WAIT = { NONE | SELF | BLOCKERS }
  • If BLOCKERS is too aggressive for your environment, consider changing it to SELF so the new request aborts instead of killing existing sessions.

Step 3: Resolve or Reschedule Blocking Transactions

  • Manually commit, roll back, or kill the blocking session using KILL <session_id> if it is safe to do so.
  • Reschedule the online index rebuild or DDL operation during a low-traffic maintenance window using SQL Server Agent Jobs.
  • In Windows Server 2025 / Windows 11, confirm no external backup agent (e.g., VSS writer for SQL) is holding a schema lock during the operation via services.msc.

Step 4: Adjust Lock Timeout and Retry Logic

  • Set an appropriate LOCK_TIMEOUT value at the session level to prevent indefinite waits:
  • SET LOCK_TIMEOUT 5000;
  • Implement retry logic in application code or SSIS/ETL packages to handle Error 1218 gracefully by re-attempting the operation after a delay.

Step 5: Validate SQL Server Patch Level

  • Confirm SQL Server 2025 is updated to the latest Cumulative Update (CU) via SQL Server Setup or SELECT @@VERSION;.
  • Apply any hotfixes related to low-priority wait handling and online indexing from the Microsoft Update Catalog.

Alternative or Verification Steps

  • Re-run the original online index or DDL operation and confirm it completes without generating Error 1218 in the SQL Server Error Log (Management > SQL Server Logs in SSMS).
  • As an alternative, run the operation with ONLINE = OFF (if downtime is acceptable) to bypass low-priority lock wait semantics entirely and confirm the underlying blocking issue is resolved.

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

Troubleshooting Guide: Error 1217 – ABORTAFTERWAIT = BLOCKERS DDL Termination

Why This Error Happens

This error occurs when a DDL statement (such as ALTER TABLE or index rebuild operations) is executed using the WAIT_AT_LOW_PRIORITY lock option combined with ABORT_AFTER_WAIT = BLOCKERS. When the DDL statement attempts to acquire a schema lock and encounters blocking sessions, SQL Server 2025 forcibly terminates those blocking processes rather than waiting indefinitely. This is a deliberate concurrency control behavior designed to prevent long-running DDL operations from being starved by ongoing transactions, but it results in active user sessions or queries being unexpectedly killed.

Step-by-Step Resolution Guide

Step 1: Identify the Blocking and Blocked Sessions

  • Query sys.dm_exec_requests and sys.dm_exec_sessions to capture session IDs active during the error window.
  • Check SQL Server Error Log (via SSMS or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the exact Process ID and database_id referenced in the message.
  • Cross-reference the killed Process ID with Extended Events or the default trace to determine which query was terminated.

Step 2: Review the Offending DDL Statement

  • Locate the DDL script (index rebuild, ALTER TABLE, partition switch, etc.) that includes WAIT_AT_LOW_PRIORITY (MAX_DURATION = x MINUTES, ABORT_AFTER_WAIT = BLOCKERS).
  • Confirm whether this option was intentionally set by a maintenance job, Ola Hallengren’s index maintenance scripts, or a custom deployment pipeline.
  • Check SQL Server Agent Job history (via SSMS > SQL Server Agent > Jobs > View History) if the DDL ran as part of a scheduled task.

Step 3: Adjust the Locking Priority Strategy

  • Change ABORT_AFTER_WAIT = BLOCKERS to ABORT_AFTER_WAIT = SELF if you prefer the DDL statement to fail instead of killing user sessions.
  • Alternatively, increase MAX_DURATION to allow more time for blocking transactions to complete naturally before any termination occurs.
  • Example corrected syntax:
  ALTER TABLE dbo.YourTable REBUILD 
  WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 10 MINUTES, ABORT_AFTER_WAIT = SELF)));

Step 4: Schedule DDL Operations During Low-Activity Windows

  • Use Windows Server 2025 Task Scheduler or SQL Server Agent to shift index maintenance and schema changes to off-peak hours.
  • Validate current workload patterns using Query Store (SSMS > Database > Query Store > Top Resource Consuming Queries) to pick a safe execution window.

Step 5: Apply Latest SQL Server 2025 Cumulative Update

  • Verify current build version with SELECT @@VERSION;.
  • Download and apply the latest Cumulative Update from the Microsoft Update Catalog, as early CU builds for SQL Server 2025 have had refinements to low-priority wait handling.

Alternative or Verification Steps

  • Verify the fix: Re-run the DDL operation during a monitored window and confirm via sys.dm_exec_requests that no unexpected session terminations appear in the SQL Server Error Log.
  • Alternative workaround: If immediate termination behavior must be preserved for maintenance SLAs, implement application-level retry logic to gracefully reconnect and resume killed transactions instead of modifying the DDL locking strategy.

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

Troubleshooting Guide: Error 1216 — ABORTAFTERWAIT = BLOCKERS Conflict with System Task

Why This Error Happens

This error occurs when a DDL statement using the WAIT_AT_LOW_PRIORITY (ABORT_AFTER_WAIT = BLOCKERS) option encounters a blocking session that is actually a system background task (such as auto-stats updates, ghost record cleanup, or a system-initiated checkpoint) rather than a user transaction. Because the ABORT_AFTER_WAIT = BLOCKERS option is specifically designed to kill only user-owned transactions that hold conflicting locks, SQL Server refuses to terminate the internal system task, causing the DDL operation to fail with Error 1216. This typically happens on tables experiencing high concurrent activity, where system maintenance operations overlap with online index rebuilds or schema changes.

Step-by-Step Resolution Guide

Step 1: Identify the Blocking System Task

  • Open a new query window in SQL Server Management Studio (SSMS) connected to the affected instance.
  • Run the following query to find blocking sessions:
SELECT session_id, blocking_session_id, wait_type, wait_time, is_user_process
FROM sys.dm_exec_requests
WHERE blocking_session_id <> 0;
  • Confirm that is_user_process = 0 for the blocking session, verifying it is a system task (e.g., SYSTEM_HEALTH, GHOST CLEANUP, or AUTO_UPDATE_STATS).

Step 2: Retry the DDL Operation Without Immediate Abort

  • Modify the original DDL statement to remove the aggressive ABORT_AFTER_WAIT = BLOCKERS clause temporarily and instead use WAIT_AT_LOW_PRIORITY (MAX_DURATION = 5 MINUTES, ABORT_AFTER_WAIT = SELF).
  • Example:
ALTER TABLE dbo.YourTable
REBUILD WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 5 MINUTES, ABORT_AFTER_WAIT = SELF)));
  • This allows the system task to finish naturally instead of forcing an abort that SQL Server will reject.

Step 3: Schedule the Operation During Low-Activity Windows

  • Check SQL Server Agent Job history in SQL Server Management Studio → SQL Server Agent → Jobs for any overlapping maintenance plans (index rebuilds, statistics updates, or integrity checks).
  • Reschedule the conflicting DDL operation to run outside of active maintenance windows, ideally during off-peak hours (e.g., 2:00 AM–4:00 AM server time).
  • On Windows Server 2025, use Task Scheduler or the native SQL Server Agent Scheduler to stagger jobs with at least a 15-minute buffer between maintenance tasks.

Step 4: Increase System Task Priority Awareness (Optional Tuning)

  • If this is a recurring issue on high-transaction tables, review sys.dm_os_waiting_tasks to confirm whether GHOST CLEANUP or LAZY WRITER tasks are frequent blockers.
  • Consider manually running DBCC SHRINKDATABASE or ghost cleanup pre-emptively during maintenance windows to reduce background task contention during business hours.

Alternative or Verification Steps

  • Verify the fix: Re-run the original DDL statement with ABORT_AFTER_WAIT = BLOCKERS during a low-activity period and confirm it completes without Error 1216.
  • Alternative workaround: If the error persists, switch to an offline maintenance window and execute the DDL change with ONLINE = OFF, bypassing the low-priority wait mechanism entirely.

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

Troubleshooting Guide: SQL Server Error 1215 — ABORTAFTERWAIT = BLOCKERS Conflict

Why This Error Happens

This error occurs when a session attempts to use the ABORT_AFTER_WAIT = BLOCKERS lock option while another transaction is already in the process of rolling back on the same resource. SQL Server disallows stacking a second high-priority lock request on top of a resource that is currently unwinding a rollback, because the engine cannot guarantee priority ordering during that transitional state. This is typically a timing/concurrency issue rather than a permissions or file corruption problem, often triggered by aggressive retry logic in application code or by online index operations (WAIT_AT_LOW_PRIORITY) colliding with long-running blocking transactions.

Step-by-Step Resolution Guide

Step 1: Identify the Blocking and Rolling-Back Sessions

  • Open SSMS and run sp_who2 or query sys.dm_exec_requests to find sessions with status = 'rollback'.
  • Use the following query to pinpoint the exact session:
  SELECT session_id, status, command, blocking_session_id, wait_type, wait_time
  FROM sys.dm_exec_requests
  WHERE command LIKE '%ROLLBACK%' OR status = 'rollback';
  • Note the session_id and blocking_session_id for cross-reference with your application logs.

Step 2: Allow the Rollback to Complete Naturally

  • Do NOT kill the rolling-back session — forcibly terminating it (KILL <session_id>) can extend rollback time or cause further corruption-like symptoms.
  • Monitor rollback progress using:
  SELECT session_id, percent_complete, estimated_completion_time
  FROM sys.dm_exec_requests
  WHERE session_id = <session_id>;
  • Wait until percent_complete reaches 100 before retrying the original operation.

Step 3: Adjust the Application/Index Retry Logic

  • If this error originates from an ALTER INDEX ... REBUILD WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY ...)) statement, modify the MAX_DURATION and ABORT_AFTER_WAIT parameters to use SELF or NONE instead of BLOCKERS for less aggressive conflict behavior.
  • Example fix in T-SQL:
  ALTER INDEX ALL ON dbo.YourTable
  REBUILD WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 5 MINUTES, ABORT_AFTER_WAIT = SELF)));
  • Update any application-level retry middleware to include an exponential backoff delay (e.g., 2–5 seconds) before resubmitting the request on Error 1215.

Step 4: Check for Long-Running Transactions Causing Repeated Rollbacks

  • Navigate to C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ and review the ERRORLOG for repeated transaction abort patterns.
  • Identify poorly optimized transactions or missing COMMIT/TRY-CATCH blocks in stored procedures that may be causing frequent incomplete transactions requiring rollback.
  • Patch the offending stored procedure or batch job to ensure explicit transaction boundaries.

Alternative or Verification Steps

  • Re-run the original query or index operation once the identified session_id rollback shows percent_complete = 100; confirm no Error 1215 is thrown in SSMS or the application log.
  • As an alternative, schedule index maintenance and other ABORT_AFTER_WAIT = BLOCKERS operations during low-traffic maintenance windows using SQL Server Agent jobs to avoid collision with active blocking transactions.

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

Why This Error Happens

SQL Server 2025 maintains an internal transaction table with a fixed structural limit for tracking active parallel transactions within the Transaction Manager (XTP/Lock Manager). This error occurs when an application opens an excessive number of simultaneous transactions without properly committing or rolling them back, often due to connection pool leaks or a runaway loop in application code. In rare cases, this can also be triggered by corrupted session state in tempdb following an unexpected server restart.

Step-by-Step Resolution Guide

Step 1: Identify the Source of Transaction Flooding

  • Open SQL Server Management Studio (SSMS) and run sys.dm_tran_active_transactions to view the current count of open transactions.
  • Cross-reference with sys.dm_exec_sessions and sys.dm_exec_requests to identify the specific host_name or program_name generating excessive transactions.
  • Check application logs (Event Viewer > Applications and Services Logs) for repeated BEGIN TRAN calls without corresponding COMMIT/ROLLBACK.

Step 2: Terminate Orphaned Sessions and Clear the Transaction Table

  • Execute KILL [session_id] on any session identified as holding an abnormally high number of open transactions.
  • If the server is unresponsive to standard commands, restart the SQL Server service via services.msc or PowerShell:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • Allow tempdb to rebuild cleanly on restart, as this clears the internal transaction tracking table.

Step 3: Adjust Application Connection Pooling and Transaction Scope

  • Review application connection strings (e.g., web.config or appsettings.json) and ensure Max Pool Size is set to a reasonable value (typically 100–200) rather than unbounded.
  • Wrap all application-level SQL transactions in try-catch-finally blocks to guarantee a COMMIT or ROLLBACK executes even on exception.
  • If using distributed transactions (MSDTC), verify MSDTC security settings under Component Services > My Computer > Distributed Transaction Coordinator on Windows Server 2025 to ensure transactions aren’t hanging mid-flight.

Step 4: Increase Monitoring and Set Alerts

  • Create a SQL Server Agent Alert on Error 1214 to proactively notify administrators before the condition recurs.
  • Configure Extended Events session to capture transaction_log and lock_escalation events for deeper diagnostics if the issue persists.

Alternative or Verification Steps

  • Verify the fix by running a load test against the application and monitoring sys.dm_tran_active_transactions to confirm the transaction count stays within normal operating thresholds (typically under a few thousand).
  • If the error persists after addressing application code, run DBCC CHECKDB to rule out underlying tempdb or system database corruption as a contributing factor.

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

Troubleshooting Guide: SQL Server Error 1213 – “Error spawning Lock Monitor thread”

Why This Error Happens

Error 1213 occurs when SQL Server’s engine attempts to initialize the internal Lock Monitor thread during startup but is denied the necessary system resources to do so. This is typically caused by the operating system running low on available worker threads, kernel memory, or non-paged pool resources, often due to constrained max worker threads configuration or system-wide resource exhaustion. In some cases, this is also triggered by corrupted thread-handling binaries or conflicting third-party security software intercepting thread creation calls.

Step-by-Step Resolution Guide

Step 1: Verify System Resource Availability

  • Open Task Manager or Resource Monitor on Windows Server 2025 / Windows 11 and check for abnormally high handle counts or thread counts system-wide.
  • Run Get-Process sqlservr | Select-Object Threads, Handles in PowerShell to inspect current SQL Server thread usage.
  • Check the Windows System Event Log for related warnings about Non-Paged Pool depletion or kernel resource limits.

Step 2: Review and Adjust the max worker threads Configuration

  • Open SQL Server Management Studio (SSMS) and connect via the Dedicated Admin Connection (DAC) if the instance is unresponsive: sqlcmd -S localhost -A.
  • Run sp_configure 'max worker threads' to check the current value; a misconfigured high value can starve the OS of threads needed for the Lock Monitor.
  • Reset the value to 0 (auto-configure) using EXEC sp_configure 'max worker threads', 0; RECONFIGURE; to let SQL Server dynamically manage thread allocation based on CPU count.

Step 3: Check for Memory and Virtual Address Space Pressure

  • Navigate to SQL Server Configuration Manager and verify the -g (memorytoreserve) startup parameter isn’t set too high, as this starves the thread pool of virtual address space.
  • If running a 32-bit legacy compatibility mode (rare in 2025 but possible in compatibility testing), ensure /3GB switches are not conflicting with modern 64-bit memory addressing.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc after adjustments to force a clean re-initialization of the Lock Manager.

Step 4: Scan for Corrupted System Files or Driver Conflicts

  • Run sfc /scannow in an elevated Command Prompt to repair corrupted Windows system files that might interfere with Win32 thread APIs.
  • Temporarily disable third-party antivirus or EDR (Endpoint Detection and Response) software, as aggressive hooking into CreateThread calls can block SQL Server’s internal monitor initialization.
  • Reboot the server to clear any hung kernel handles before restarting the SQL Server service.

Alternative or Verification Steps

  • Verification: After restarting the service, query SELECT * FROM sys.dm_os_threads WHERE status = 'Lock Monitor'; to confirm the thread is active and running without errors in the SQL Server Error Log.
  • Alternative: If the error persists, rebuild the master database using the setup.exe /ACTION=REBUILDDATABASE command line utility, as a corrupted master database can sometimes prevent internal threads from spawning correctly during boot-up.

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

Troubleshooting Guide: SQL Server Error 1212 – “Lock Not Logged”

Why This Error Happens

Error 1212 occurs when SQL Server’s Lock Manager encounters an internal failure while attempting to log a lock resource during deadlock detection or lock monitoring output, often tied to tempdb contention or insufficient memory for the lock structure allocation. This typically surfaces when the Lock Manager subsystem is overwhelmed by a high volume of concurrent lock requests exceeding available memory grants, or when internal lock metadata becomes corrupted due to abrupt resource pressure. In Windows Server 2025 environments, this can also be triggered by misconfigured memory limits or outdated SQL Server 2025 cumulative updates that have known lock manager instability.

Step-by-Step Resolution Guide

Step 1: Verify SQL Server Memory Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run EXEC sp_configure 'max server memory' to check current allocation.
  • Ensure at least 20% of total system RAM remains available to the OS on Windows Server 2025, especially if running alongside other services.
  • Adjust using sp_configure 'max server memory (MB)', <value> followed by RECONFIGURE.

Step 2: Check and Clear Tempdb Contention

  • Query sys.dm_db_file_space_usage to inspect tempdb space allocation.
  • Verify tempdb has multiple data files configured (recommended: one file per 4 CPU cores, up to 8 files).
  • Navigate to SSMS > Databases > tempdb > Properties > Files and add additional files if only one exists.
  • Restart the SQL Server service via Services.msc or net stop MSSQLSERVER && net start MSSQLSERVER after changes.

Step 3: Apply Latest Cumulative Update

  • Check current build version with SELECT @@VERSION.
  • Download the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog.
  • Run the installer with elevated privileges (Right-click > Run as Administrator).
  • Reboot Windows Server 2025 / Windows 11 after installation completes to finalize lock manager fixes.

Step 4: Review SQL Server Error Log for Correlated Events

  • Navigate to SSMS > Management > SQL Server Logs.
  • Look for correlated Event IDs (such as 17053 or 833) occurring around the same timestamp as Error 1212.
  • Cross-reference with Windows Event Viewer under Windows Logs > Application for disk I/O or memory pressure warnings.

Alternative or Verification Steps

  • Run a manual deadlock trace using DBCC TRACEON (1222, -1) and monitor the SQL Error Log for clean deadlock graph output without Error 1212 recurring.
  • If the issue persists, failover to a secondary replica (if using Always On Availability Groups) and rebuild tempdb on the primary node using ALTER DATABASE tempdb MODIFY FILE before failing back.

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

Troubleshooting Guide: SQL Server Error 1210 – Lock Owner Block Allocation Failure

Why This Error Happens

Error 1210 occurs when SQL Server 2025 runs out of available memory in the lock manager pool while attempting to migrate lock owner blocks between transactions, typically during high-concurrency workloads or large batch operations. This is commonly caused by insufficient memory allocated to the SQL Server instance, excessive lock escalation due to poorly optimized queries, or memory pressure from competing processes on Windows Server 2025. In some cases, corrupted memory-mapped pages in the tempdb database or a misconfigured max server memory setting can prevent the lock manager from reserving contiguous memory for lock owner blocks, causing the server to halt as a protective measure.

Step-by-Step Resolution Guide

Step 1: Verify and Adjust SQL Server Memory Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run EXEC sys.sp_configure 'max server memory' to check the current allocation.
  • Ensure at least 20% of physical RAM is reserved for the OS; for example, on a 64GB server, set max server memory to no more than 51200 MB using:
    EXEC sp_configure 'max server memory', 51200; RECONFIGURE;
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Step 2: Clear and Rebuild tempdb Database

  • Navigate to the tempdb data file location, typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\.
  • Stop the SQL Server service completely.
  • Delete or rename the existing tempdb.mdf and templog.ldf files if corruption is suspected.
  • Restart the SQL Server service to force automatic recreation of tempdb files with default settings.

Step 3: Review and Optimize Lock Escalation Settings

  • Query active lock escalation events using:
    SELECT * FROM sys.dm_tran_locks WHERE request_status = 'WAIT';
  • Identify tables with excessive row-level locks that are escalating to table-level locks.
  • Apply the ALTER TABLE [TableName] SET (LOCK_ESCALATION = AUTO); setting on high-contention tables.
  • Update query indexes using ALTER INDEX ALL ON [TableName] REBUILD; to reduce lock duration.

Step 4: Increase Windows Server Virtual Memory (Pagefile)

  • Open System Properties on Windows Server 2025 via sysdm.cpl.
  • Navigate to Advanced > Performance Settings > Advanced > Virtual Memory > Change.
  • Set a custom size with an initial value of 1.5x physical RAM and maximum of 3x physical RAM.
  • Click Set, then OK, and restart the server to apply changes.

Alternative or Verification Steps

  • After applying the fixes, monitor SQL Server logs at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for recurrence of Error 1210 over a 24-48 hour period under normal load.
  • If the issue persists, run DBCC CHECKDB against all production databases to rule out underlying page corruption, and consider applying the latest SQL Server 2025 Cumulative Update from Microsoft’s official download center.

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

Troubleshooting Guide: SQL Server Error 1209 – “Could Not Allocate Initial Lock Owner Blocks”

Why This Error Happens

This error occurs when SQL Server 2025 fails to allocate memory for its internal lock management structures during the startup sequence, typically because the system has insufficient available physical memory or the memory is too fragmented to satisfy the contiguous allocation request. It can also be triggered by an incorrectly configured “max server memory” or “min server memory” setting that conflicts with the resources actually available on the Windows Server 2025 / Windows 11 host. In some cases, this is a symptom of resource exhaustion caused by other applications, virtualization overhead, or a misconfigured memory-mapped file limit on the OS level.

Step-by-Step Resolution Guide

Step 1: Verify Available System Memory

  • Open Task Manager or Performance Monitor (perfmon.exe) and check the Available MBytes counter under the Memory section.
  • Confirm that the server has not hit a physical RAM ceiling due to other services (IIS, SSAS, SSRS) competing for memory.
  • If running in a virtual machine, check the hypervisor (Hyper-V/VMware) for dynamic memory ballooning that may be starving the guest OS.

Step 2: Reset SQL Server Memory Configuration via Startup Parameters

  • Since SQL Server won’t start normally, launch it in minimal configuration mode from an elevated Command Prompt:
  • NET START MSSQLSERVER /f /T3608
  • Once connected via SQLCMD, reset the memory caps to default values:
  • sp_configure 'show advanced options', 1; RECONFIGURE;
  • sp_configure 'min server memory', 0;
  • sp_configure 'max server memory', 2147483647;
  • RECONFIGURE;
  • Stop the instance and restart it normally: NET STOP MSSQLSERVER then NET START MSSQLSERVER.

Step 3: Check the Windows “Lock Pages in Memory” Policy

  • Open gpedit.msc and navigate to Computer Configuration > Windows Settings > Security Settings > Local Policies > User Rights Assignment.
  • Ensure the SQL Server service account has been granted the Lock pages in memory permission.
  • If this policy is missing or incorrectly revoked, SQL Server may be unable to reserve the contiguous blocks needed for lock owner structures.
  • Run gpupdate /force and reboot the server to apply the policy change.

Step 4: Increase Virtual Memory / Page File Size

  • Navigate to System Properties > Advanced > Performance Settings > Advanced > Virtual Memory.
  • Set the page file to a custom size that is at least 1.5x the physical RAM installed (e.g., 24GB RAM = 36GB page file).
  • Apply the changes and reboot the Windows Server 2025 / Windows 11 machine to ensure the new page file settings are initialized before SQL Server starts.

Step 5: Check for Address Windowing Extensions (AWE) Conflicts

  • If running a 32-bit legacy instance (rare in 2025 environments but possible in compatibility mode), verify that awe enabled is correctly set in sp_configure.
  • For 64-bit native installations, ensure no legacy AWE registry keys are forcing an invalid memory addressing mode in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer.

Alternative or Verification Steps

  • Verification: After restarting the service, check the SQL Server Error Log (ERRORLOG file located in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\LOG\) to confirm the service started without the 1209 error and that “SQL Server is now ready for client connections” appears.
  • Alternative: If the error persists despite available RAM, uninstall and reinstall the SQL Server instance using the command line with explicit memory parameters (/SQLSVCINSTANTFILEINIT="TRUE") to rule out a corrupted binary or installation file causing the allocation failure.

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

Troubleshooting Guide: SQL Server Error 1208 — “Could Not Allocate Initial Lock Blocks”

Why This Error Happens

This error occurs when SQL Server 2025 cannot reserve enough contiguous virtual memory during startup to initialize its internal lock management structures. It is typically caused by insufficient system memory, memory pressure from other applications, restrictive memory configuration settings (such as a misconfigured max server memory or min server memory value), or a lack of the “Lock Pages in Memory” privilege for the SQL Server service account. In some cases, this can also stem from a corrupted or misconfigured master database affecting startup parameters.

Step-by-Step Resolution Guide

Step 1: Verify Available System Memory and Close Competing Processes

  • Open Task Manager or Performance Monitor and check available physical memory before attempting to restart the SQL Server service.
  • Close unnecessary applications or services consuming high memory, especially other database engines or virtualization software.
  • On Windows Server 2025, check Resource Monitor for memory leaks caused by background services.

Step 2: Grant “Lock Pages in Memory” Privilege to the SQL Server Service Account

  • Open the Local Security Policy editor by running secpol.msc.
  • Navigate to Local Policies > User Rights Assignment > Lock pages in memory.
  • Add the SQL Server service account (e.g., NT SERVICE\MSSQLSERVER) to this policy.
  • Restart the SQL Server service for the privilege change to take effect.

Step 3: Adjust SQL Server Startup Parameters and Memory Settings

  • Open SQL Server Configuration Manager and locate the SQL Server service properties.
  • Under the Startup Parameters tab, verify there are no conflicting or malformed parameters (e.g., incorrect -g memory-to-reserve flag).
  • If using a fixed min server memory, temporarily lower the value using the following startup trace flag to bypass normal allocation checks: -T3608 (minimal startup mode), then adjust memory settings once the instance is up.
  • Example command to start SQL Server in minimal configuration mode via Command Prompt:
  • NET START MSSQLSERVER /f /T3608

Step 4: Check for Virtual Memory / Paging File Constraints

  • Open System Properties > Advanced > Performance Settings > Advanced tab on Windows Server 2025 or Windows 11.
  • Confirm the paging file size is set to “System managed size” or manually increased if system RAM is limited.
  • Reboot the server after adjusting paging file settings and attempt to start the SQL Server service again.

Step 5: Review SQL Server Error Logs for Additional Clues

  • Navigate to the default log path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • Look for preceding error messages related to memory allocation failures or insufficient virtual address space.
  • Cross-reference any additional Event IDs logged in Windows Event Viewer under Applications and Services Logs > MSSQLSERVER.

Alternative or Verification Steps

  • After applying the fixes, restart the SQL Server service normally (without -T3608) and confirm Error 1208 no longer appears in the ERRORLOG or Event Viewer.
  • If the issue persists, consider running SQL Server as a 64-bit instance (if not already) or increasing the virtual machine’s allocated RAM, since 32-bit instances or low-memory VMs are especially prone to this allocation failure.

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

Troubleshooting Guide: SQL Server Error 1207 – “Can’t Allocate %u Locks on Startup”

Why This Error Happens

This error occurs when SQL Server 2025 is configured with a static, manually-set value for the locks configuration option that exceeds the available memory the server can allocate at startup. Typically, this happens after a server migration or hardware downgrade where the min server memory or locks setting was hardcoded based on the specs of a more powerful machine. Because lock structures are allocated from the buffer pool during the startup sequence, insufficient physical RAM or a conflicting memory configuration will cause the Database Engine to fail this allocation and halt startup.

Step-by-Step Resolution Guide

Step 1: Start SQL Server in Minimal Configuration Mode

  • Since the Database Engine won’t start normally, you need to bypass the faulty locks setting.
  • Open Command Prompt as Administrator and navigate to the Binn directory (e.g., cd "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn").
  • Run the engine with the -f flag to force minimal configuration: sqlservr.exe -f -m -s MSSQLSERVER.

Step 2: Reset the Locks Configuration via SQLCMD

  • While the instance is running in minimal mode (leave the previous Command Prompt window open), open a second Command Prompt window.
  • Connect to the instance using SQLCMD: sqlcmd -S .\MSSQLSERVER.
  • Execute the following T-SQL commands to reset the locks value to dynamic (0), which allows SQL Server to manage memory automatically:
  • EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
  • EXEC sp_configure 'locks', 0; RECONFIGURE;

Step 3: Verify System Memory and Restart the Service

  • Close the minimal configuration session (Ctrl+C in the first window and confirm shutdown) to release the port.
  • Check the Windows Server 2025 Task Manager or Resource Monitor to ensure the host OS has sufficient free RAM (at least 2GB more than the SQL Server max server memory setting) to support the startup overhead.
  • Restart the SQL Server service via services.msc or by running: net start MSSQLSERVER.

Step 4: Inspect the Error Log for Persistent Issues

  • If the service fails again, navigate to the Log folder (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • Look for conflicting memory pressure settings, such as a max server memory value set too low to support the minimum required locks for the current workload.

Alternative or Verification Steps

  • Verification: Once the service starts successfully, run SELECT * FROM sys.dm_os_sys_info; to confirm the max_workers_count and memory clerks are initializing correctly without throttling.
  • Alternative: If the server continues to fail due to physical RAM constraints, consider adding a startup parameter in SQL Server Configuration Manager to limit the -g (memory to reserve) setting, freeing up more space for the lock manager during the boot sequence.

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

Troubleshooting Guide: MS DTC Error 1206 – Distributed Transaction Cancelled

Why This Error Happens

Error 1206 occurs when the Microsoft Distributed Transaction Coordinator (MS DTC) aborts a transaction because a participating resource manager failed to respond or vote within the designated timeout window. This is most commonly caused by MS DTC security configuration mismatches between the two servers (one allowing inbound/outbound network transactions while the other blocks them), firewall rules blocking RPC/DTC traffic on port 135 and its dynamic range, or authentication failures due to disabled “No Authentication Required” settings when NTLM/Kerberos negotiation fails between untrusted domains. In some cases, a corrupted or misconfigured MSDTC service instance on SQL Server 2025 (especially with the new per-database DTC isolation feature) can also trigger premature transaction cancellation.

Step-by-Step Resolution Guide

Step 1: Verify and Align MS DTC Security Settings on Both Servers

  • Open Component Services (dcomcnfg.exe) on both the SQL Server and the client/application server.
  • Navigate to Component Services > Computers > My Computer > Distributed Transaction Coordinator > Local DTC.
  • Right-click Local DTC → Properties → Security tab.
  • Ensure these checkboxes are identical on both machines: Network DTC Access, Allow Inbound, Allow Outbound, and Enable XA Transactions (if applicable).
  • Set Authentication to No Authentication Required only if servers are in different domains without trust; otherwise use Mutual Authentication Required.

Step 2: Open Required Firewall Ports for RPC and DTC Traffic

  • Open Windows Defender Firewall with Advanced Security on both servers.
  • Create an inbound rule allowing RPC Endpoint Mapper (TCP 135).
  • Create an inbound rule allowing the program msdtc.exe (typically located at C:\Windows\System32\msdtc.exe) for all ports.
  • If using a custom RPC port range, verify it via registry key HKLM\Software\Microsoft\Rpc\Internet and open that specific range in the firewall.
  • Restart the Distributed Transaction Coordinator service after changes:
  net stop msdtc
  net start msdtc

Step 3: Check SQL Server 2025 DTC Isolation and Linked Server Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance.
  • Run the following query to confirm DTC support is enabled for the database:
  SELECT name, is_distributed_tran_enabled FROM sys.databases WHERE name = 'YourDatabaseName';
  • If is_distributed_tran_enabled returns 0, enable it with:
  ALTER DATABASE YourDatabaseName SET DTC_SUPPORT = ENABLED;
  • For linked servers, verify the RPC and RPC OUT options are set to true using sp_serveroption.

Step 4: Rebuild or Reset the MSDTC Service (If Corruption Is Suspected)

  • Open an elevated Command Prompt.
  • Uninstall and reinstall the MSDTC service using:
  msdtc -uninstall
  msdtc -install
  • Reboot the server to fully reinitialize the DTC log files located at C:\Windows\System32\MSDTC\MSDTC.LOG.
  • Reapply the security settings from Step 1 after reinstalling, as they reset to default.

Alternative or Verification Steps

  • Use the built-in DTC Ping Tool (DTCPing.exe) between both servers to confirm successful two-way communication before retrying the transaction.
  • If the error persists, check the Windows Event Viewer under Applications and Services Logs > Microsoft > Windows > DistributedTransactionCoordinator for specific sub-error codes that pinpoint whether the failure is authentication-based or network-based.

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

Troubleshooting Guide: Error 1205 – Transaction Deadlock Victim

Why This Error Happens

This error occurs when two or more transactions in SQL Server 2025 hold locks on resources (rows, pages, or tables) that each other’s transactions need, creating a circular dependency that cannot be resolved. SQL Server’s deadlock monitor detects this cyclical blocking condition and automatically terminates one transaction (the “victim”) to allow the other to proceed. This is typically caused by inefficient query design, missing indexes causing broader lock scopes, long-running transactions, or inconsistent object access order across concurrent sessions.

Step-by-Step Resolution Guide

Step 1: Capture Deadlock Graph Details

  • Enable trace flag 1222 to log deadlock graphs to the SQL Server error log: DBCC TRACEON (1222, -1).
  • Alternatively, configure a Extended Events session using the built-in system_health session or create a custom session targeting the xml_deadlock_report event.
  • Locate the SQL Server error log via SQL Server Management Studio (SSMS) under Management > SQL Server Logs, or check the physical log path at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.

Step 2: Analyze the Deadlock Graph

  • Open the captured XML deadlock graph in SSMS by right-clicking the event in Extended Events and selecting View Target Data.
  • Identify the two conflicting processes, the specific resources (table/index names), and the lock types (e.g., KEY, PAGE, RID) involved.
  • Note the exact T-SQL statements and execution plans associated with each session to determine the conflicting access pattern.

Step 3: Optimize Indexing and Query Logic

  • Add or modify indexes on the involved tables to reduce lock footprint, particularly covering indexes that avoid key lookups.
  • Ensure all transactions access tables in the same consistent order (e.g., always Table A before Table B) across all stored procedures and application code.
  • Wrap multi-statement transactions in explicit BEGIN TRANSACTION / COMMIT blocks with the shortest possible duration to minimize lock hold time.

Step 4: Adjust Isolation Level or Locking Hints

  • Consider changing the database isolation level to READ_COMMITTED_SNAPSHOT to reduce blocking: ALTER DATABASE [YourDB] SET READ_COMMITTED_SNAPSHOT ON;.
  • For specific high-contention queries, apply locking hints such as WITH (ROWLOCK) or WITH (UPDLOCK, HOLDLOCK) where appropriate to control lock granularity.
  • Review application-level retry logic to ensure deadlock victims are automatically retried using TRY...CATCH blocks with error number 1205 detection.

Step 5: Implement Application-Level Retry Logic

  • Modify the data access layer to catch SQL error 1205 and automatically resubmit the transaction after a short delay (e.g., 100-500ms with exponential backoff).
  • Limit retry attempts to 3-5 to prevent infinite loop scenarios under sustained contention.

Alternative or Verification Steps

  • Re-run the previously failing workload under load testing while monitoring the system_health Extended Events session; confirm no new xml_deadlock_report events are generated over a sustained period.
  • If deadlocks persist despite indexing changes, consider using sp_getapplock to serialize access to critical sections of code, or set a deadlock priority using SET DEADLOCK_PRIORITY to control which session is chosen as the victim.

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

Troubleshooting Guide: SQL Server Error 1204 — Lock Resource Exhaustion

Why This Error Happens

Error 1204 occurs when SQL Server runs out of memory allocated for managing lock structures, typically because the internal lock table has reached its capacity. This is commonly caused by excessively large or long-running transactions that acquire thousands of row, page, or table locks, combined with insufficient memory being available to the SQL Server instance. On Windows Server 2025 / Windows 11 systems, this can also be triggered by memory pressure from other processes competing for RAM, or by a manually configured locks setting in sp_configure that is set too low for the workload.

Step-by-Step Resolution Guide

Step 1: Check Current Lock and Memory Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run EXEC sp_configure 'locks'; to check if a static lock limit has been manually set (0 = dynamic, which is recommended).
  • Run EXEC sp_configure 'max server memory'; to verify SQL Server isn’t being artificially capped below available system RAM.
  • Check Task Manager (Ctrl+Shift+Esc) on Windows Server 2025 to confirm available physical memory isn’t critically low.

Step 2: Identify and Kill the Offending Transaction

  • Run the following query to find sessions holding excessive locks:
  SELECT request_session_id, COUNT(*) AS lock_count
  FROM sys.dm_tran_locks
  GROUP BY request_session_id
  ORDER BY lock_count DESC;
  • Identify the session_id with the highest lock_count.
  • If a runaway transaction is confirmed, terminate it using KILL <session_id>; (replace with the actual ID).

Step 3: Reset Locks to Dynamic Allocation

  • If the locks parameter in Step 1 returned a non-zero value, reset it to dynamic management:
  EXEC sp_configure 'show advanced options', 1;
  RECONFIGURE;
  EXEC sp_configure 'locks', 0;
  RECONFIGURE;
  • Restart the SQL Server service via services.msc or by running net stop MSSQLSERVER && net start MSSQLSERVER in an elevated Command Prompt.

Step 4: Optimize Transaction Design and Indexing

  • Review application code or stored procedures for transactions that update/delete large batches of rows in a single statement.
  • Break large batch operations into smaller chunks (e.g., using TOP (1000) in a loop) to reduce the number of concurrent locks held.
  • Verify appropriate indexes exist on filtered columns using the Database Engine Tuning Advisor to reduce the need for full table scans and widespread row locking.

Step 5: Increase Physical or Allocated Memory

  • Navigate to Server Properties > Memory in SSMS and increase the “Maximum server memory” value if the Windows host has available unused RAM.
  • Ensure the Windows Server 2025 host itself is not memory-starved by other co-located services (e.g., IIS, Active Directory roles) running on the same box.

Alternative or Verification Steps

  • Verify the fix: Re-run the failing query or batch process during peak load; monitor sys.dm_os_memory_clerks filtered by MEMORYCLERK_LOCK_MANAGER to confirm memory usage remains stable and does not spike to the previous failure threshold.
  • Alternative solution: If the server has limited physical RAM, consider enabling “Lock Pages in Memory” via the Local Security Policy (secpol.msc under User Rights Assignment) to prevent the OS from paging out SQL Server’s memory allocations, which can indirectly free up resources for lock management.

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

Troubleshooting Guide: SQL Server Error 1203

Why This Error Happens

Error 1203 occurs when SQL Server’s internal lock manager detects that a process (SPID) is attempting to release a lock on a resource it never actually acquired. This is typically caused by internal lock structure corruption, often resulting from memory pressure, a corrupted query plan in cache, or a bug triggered by parallel query execution (CXPACKET) threads mishandling shared resources. It can also surface due to hardware-level memory errors or outdated SQL Server 2025 cumulative updates that mishandle lock escalation during high-concurrency transactions.

Step-by-Step Resolution Guide

Step 1: Clear the Procedure Cache and Retry

  • This resolves issues caused by a corrupted execution plan that mismanages locking logic.
  • Run the following command in SQL Server Management Studio (SSMS): DBCC FREEPROCCACHE;
  • Immediately retry the transaction that threw the 1203 error to see if it completes successfully.

Step 2: Disable Parallelism for the Problematic Query

  • Error 1203 is frequently tied to parallel execution threads losing track of lock ownership.
  • Identify the specific query using sys.dm_exec_query_stats and add the query hint OPTION (MAXDOP 1) to the end of the statement.
  • Alternatively, lower the server-wide “Max Degree of Parallelism” setting via SSMS: Right-click Server Instance > Properties > Advanced > Max Degree of Parallelism > Set to 1 for testing.

Step 3: Check for Memory Pressure and Hardware Errors

  • Insufficient memory can cause SQL Server to prematurely deallocate lock structures.
  • Open Windows Event Viewer (eventvwr.msc) and check the System log for Event ID 2019 (Memory Pool) or hardware-specific MCE (Machine Check Exception) errors.
  • Ensure “Max Server Memory” in SQL Server is configured to leave at least 4GB free for the Windows Server 2025 OS.

Step 4: Apply the Latest Cumulative Update (CU)

  • Microsoft frequently patches lock manager bugs in SQL Server 2025 CUs.
  • Navigate to the Microsoft documentation site and download the latest CU for SQL Server 2025.
  • Install the update during a maintenance window and restart the SQL Server (MSSQLSERVER) service via services.msc.

Step 5: Run Hardware Diagnostics (DBCC CHECKDB)

  • Rule out underlying disk or database corruption that might be causing resource misallocation.
  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to check for integrity issues.
  • Review the output for any allocation errors that correlate with the locking resource mentioned in the error log.

Alternative or Verification Steps

  • Verification: Monitor the SQL Server Error Log (via SSMS > Management > SQL Server Logs) for 24-48 hours to confirm Error 1203 does not reappear after applying the CU and adjusting MAXDOP.
  • Alternative: If the error persists only on specific queries, rewrite the query to avoid complex JOIN hints or explicit locking (e.g., TABLOCKX) which can confuse the lock manager during parallel processing.

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

Troubleshooting Guide: SQL Server Error 1202 – “The database-principal ‘%.*ls’ does not exist or user is not a member”

Why This Error Happens

This error occurs when SQL Server attempts to execute a role membership change (such as ALTER ROLE... ADD MEMBER or sp_addrolemember) but cannot locate the specified database-principal within the current database context. This typically happens due to a mismatch between the login’s Security Identifier (SID) and the database user’s SID, often caused by restoring a database from a different server or instance. It can also occur when a user was dropped from the database but remnants of permission-granting scripts still reference the stale principal name.

Step-by-Step Resolution Guide

Step 1: Verify the Principal Exists in the Database

  • Open SQL Server Management Studio (SSMS) and connect to the SQL Server 2025 instance.
  • Run the following query against the target database to confirm the user exists:
  SELECT name, type_desc, sid FROM sys.database_principals WHERE name = 'YourUserName';
  • If no rows are returned, the user does not exist in the database and must be created or re-mapped.

Step 2: Identify and Fix Orphaned Users

  • Orphaned users (where the Login SID does not match the Database User SID) are the most common cause of Error 1202 on restored databases.
  • Run sp_change_users_login 'Report'; on the database to list orphaned accounts.
  • Re-link the orphaned user to the correct Windows Server 2025 login using:
  ALTER USER [YourUserName] WITH LOGIN = [YourUserName];
  • Alternatively, if the login does not exist, create it first via CREATE LOGIN [YourUserName] FROM WINDOWS; for Windows 11 Active Directory accounts.

Step 3: Recreate the Database Principal

  • If Step 1 confirmed the user is entirely missing, create the user explicitly within the correct database context.
  • Execute:
  USE [YourDatabaseName];
  CREATE USER [YourUserName] FOR LOGIN [YourUserName];
  • Ensure you are running this in the context of the specific database (not master), as role membership is database-scoped.

Step 4: Add the User to the Required Role

  • Once the principal is confirmed to exist, retry the original role assignment command that triggered the error.
  • Execute:
  ALTER ROLE [db_datareader] ADD MEMBER [YourUserName];
  • Check the SQL Server Error Log (via Event Viewer > Applications and Services Logs > MSSQLSERVER) to confirm no further SID conflicts are logged.

Alternative or Verification Steps

  • Verification: Re-run SELECT * FROM sys.database_role_members joined with sys.database_principals to confirm the specific user now appears under the intended role ID.
  • Alternative: If SID mismatches persist across multiple users after a migration to Windows Server 2025, run the bulk remapping script using sp_change_users_login 'Auto_Fix', 'UserName' for each affected account to automatically re-sync Login SIDs with Database User SIDs.

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

Troubleshooting Guide: SQL Server Error 1138 – TempDB Workload Group Limit Exceeded

Why This Error Happens

This error occurs when SQL Server’s Resource Governor has a configured workload group with a resource pool limit that restricts the amount of memory or space tempdb can consume, and a query or session has hit that ceiling. It typically arises when a classifier function assigns sessions to a workload group with an undersized MAX_MEMORY_PERCENT or MIN_MEMORY_PERCENT setting relative to the actual tempdb workload (e.g., heavy sorts, hash joins, or large temporary table usage). This can also surface after an upgrade to SQL Server 2025 if default Resource Governor pools were migrated with conservative limits that don’t match the new workload patterns on Windows Server 2025 or Windows 11 hosts.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Workload Group

  • Run SELECT * FROM sys.dm_resource_governor_workload_groups; to list all configured groups and their current memory grants.
  • Cross-reference the %ls value from the error message with the name column to pinpoint the exact group hitting the limit.
  • Check sys.dm_resource_governor_resource_pools to see the parent pool’s max_memory_percent and current usage stats.

Step 2: Adjust the Resource Pool and Workload Group Limits

  • Open SQL Server Management Studio (SSMS) and connect to the instance, or use a query window with sysadmin rights.
  • Run an ALTER RESOURCE POOL statement to raise the memory ceiling, for example:
  ALTER RESOURCE POOL [YourPoolName] 
  WITH (MAX_MEMORY_PERCENT = 50);
  • Follow with ALTER WORKLOAD GROUP [YourGroupName] WITH (REQUEST_MAX_MEMORY_GRANT_PERCENT = 25); to loosen the per-request cap.
  • Apply changes immediately with ALTER RESOURCE GOVERNOR RECONFIGURE;.

Step 3: Review and Optimize TempDB Configuration

  • Confirm tempdb has enough data files matching logical CPU core count (up to 8), located on fast local SSD storage rather than a network share.
  • Check file growth settings via sys.master_files to ensure autogrowth isn’t throttled too low, causing repeated allocation failures.
  • On Windows Server 2025/Windows 11, verify the volume hosting tempdb isn’t near capacity using Disk Management or Get-PSDrive in PowerShell.

Step 4: Re-Evaluate the Classifier Function Logic

  • Open the user-defined classifier function (if one exists) under Programmability > Functions in SSMS.
  • Confirm sessions aren’t being inadvertently routed into an overly restrictive workload group due to flawed logic (e.g., misclassifying batch jobs as low-priority).
  • Adjust the function or reassign the application login to a less restrictive group if appropriate.

Alternative or Verification Steps

  • Re-run the failing query or job and monitor sys.dm_resource_governor_workload_groups in real time to confirm memory grants no longer hit the ceiling.
  • If the error persists, temporarily disable Resource Governor altogether with ALTER RESOURCE GOVERNOR DISABLE; to confirm it’s the root cause, then re-enable with corrected settings once validated.

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

Troubleshooting Guide: Error 1137 – Database File Limit Exceeded on Next-Gen General Purpose Instances

Why This Error Happens

This error occurs because Microsoft SQL Server 2025’s Next-Gen General Purpose tier enforces a hard-coded ceiling on the number of physical database files (.mdf/.ndf/.ldf) that can be attached to a single instance, which is a new architectural constraint tied to the service tier’s storage virtualization layer. It is typically triggered when a database was migrated from a legacy tier, when automated scripts create excessive filegroups/files for parallel bulk-load operations, or when a third-party tool spins up per-partition files without consolidating them. Unlike older SQL Server versions, this limit cannot be bypassed via trace flags or sp_configure, since it is enforced at the resource governor level of the Next-Gen tier.

Step-by-Step Resolution Guide

Step 1: Identify the Current File Count and Threshold

  • Run the following query to see how many files exist against the current limit: SELECT COUNT(*) AS FileCount, DB_NAME() AS DatabaseName FROM sys.database_files;
  • Cross-reference this count against the documented %d limit shown in the Error 1137 message (check SQL Server Error Log via EventVwr.msc under Applications and Services Logs > MSSQLSERVER).
  • Note which filegroups contain the excess files, especially ones from legacy PRIMARY or FILESTREAM groups.

Step 2: Consolidate Excess Database Files

  • Use DBCC SHRINKFILE ('logical_file_name', EMPTYFILE) to migrate data out of files you intend to remove.
  • Execute ALTER DATABASE [YourDB] REMOVE FILE logical_file_name; once the file reports zero data pages.
  • Repeat this process for secondary data files until the total count falls below the Next-Gen tier threshold (commonly 32 for General Purpose, verify via sys.dm_db_service_tier_properties).

Step 3: Adjust the Service Tier or File Architecture

  • If consolidation isn’t feasible due to data volume, open SQL Server Configuration Manager and verify the instance is correctly flagged as “Next-Gen General Purpose” rather than a mismatched legacy profile causing a false-positive file count.
  • For Windows Server 2025 hosts, check the registry key at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer\NextGenTierConfig to confirm the MaxDatabaseFiles value matches your licensing tier.
  • If the workload genuinely requires more files, upgrade the instance to the Business Critical or Hyperscale tier, which lifts this specific file-count restriction.

Step 4: Restart the SQL Server Service

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Restart the SQL Server (MSSQLSERVER) service to clear any cached metadata regarding the file-count validation check.
  • Re-attempt the original operation (e.g., CREATE DATABASE or ALTER DATABASE ADD FILE) that triggered Error 1137.

Alternative or Verification Steps

  • Verify the fix by querying sys.database_files again and confirming the count is now below the tier’s documented maximum; the original DDL command should execute without Error 1137.
  • If the error persists after consolidation, use Azure Data Studio or SSMS 21+ to run the “Service Tier Diagnostics” report, which will explicitly flag if a stale tier cache on the Windows host is misreporting the file limit.

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

Troubleshooting Guide: SQL Server Error 1136 – tempdb Storage Service Limit Exceeded

Why This Error Happens

This error occurs when tempdb’s data files grow beyond the storage allocation limit assigned to the current service tier, which is common in Azure SQL-managed instances or storage-constrained deployments running on Windows Server 2025. The root cause is typically a combination of heavy temporary object usage (large sort operations, hash joins, or temp tables) combined with an undersized tempdb allocation that wasn’t scaled to match workload demands. Additionally, uncommitted long-running transactions or version store bloat from snapshot isolation can rapidly consume tempdb space without being released back to the OS.

Step-by-Step Resolution Guide

Step 1: Identify Current tempdb Usage and Limits

  • Open SQL Server Management Studio (SSMS) and run: SELECT SUM(size) * 8 / 1024 AS SizeMB FROM tempdb.sys.database_files;
  • Check current tier limits via sys.dm_db_file_space_usage to see allocated vs. used space.
  • Review the SQL Server error log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for repeated 1136 entries and timestamps correlating with high-load periods.

Step 2: Scale Up the Service Tier or Increase tempdb Allocation

  • If running on a managed tier, navigate to the Azure Portal or local service tier configuration panel and upgrade to a tier with higher temporary storage limits.
  • For on-premises Windows Server 2025 instances, manually expand tempdb files using: ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 20480MB);
  • Ensure the underlying disk volume (preferably SSD-backed) has sufficient free space; check via Get-PSDrive in PowerShell.

Step 3: Kill or Optimize Long-Running Queries Consuming tempdb

  • Run SELECT session_id, request_id, SUM(internal_objects_alloc_page_count) AS AllocatedPages FROM sys.dm_db_task_space_usage GROUP BY session_id, request_id ORDER BY AllocatedPages DESC; to find top consumers.
  • Terminate problematic sessions using KILL <session_id>; only after confirming they are not critical production transactions.
  • Optimize queries with excessive sorting or temp table usage by adding appropriate indexes or rewriting logic to reduce intermediate result set sizes.

Step 4: Enable tempdb Auto-Growth Monitoring and Alerts

  • Configure a SQL Server Agent Alert on Error 1136 via SSMS under SQL Server Agent > Alerts > New Alert, setting the error number to 1136.
  • Set up a scheduled job to email DBAs when tempdb usage crosses 80% of its allocated limit, using sp_send_dbmail.

Alternative or Verification Steps

  • After applying fixes, re-run the query SELECT SUM(size) * 8 / 1024 AS SizeMB FROM tempdb.sys.database_files; and confirm the value stays below the new allocation threshold during peak load.
  • If the error persists after scaling, consider isolating heavy tempdb consumers onto a dedicated instance or restarting the SQL Server service (Restart-Service MSSQLSERVER) to clear residual version store bloat as a temporary workaround.

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

Troubleshooting Guide: Error 1135 – Log File Size Exceeds Maximum Allowed Size on Azure SQL

Why This Error Happens

This error occurs because Azure SQL Database enforces a hard cap on transaction log file size based on the service tier and compute size of the target database, and the source database’s log file exceeds that threshold. It commonly happens when restoring an on-premises SQL Server 2025 database (with a large or bloated log file due to long-running transactions, uncommitted transactions, or infrequent log backups) into an Azure SQL environment with a lower service tier. The restore engine rejects the operation outright because the destination simply cannot allocate a log file large enough to accommodate the incoming VLF (Virtual Log File) structure.

Step-by-Step Resolution Guide

Step 1: Shrink the Source Database Log File Before Export

  • On the source SQL Server 2025 instance, run DBCC SQLPERF(LOGSPACE) to check current log file size and percent used.
  • Perform a full log backup first: BACKUP LOG [YourDB] TO DISK = 'C:\Backups\YourDB_Log.trn'.
  • Shrink the log file using DBCC SHRINKFILE (YourDB_log, 1024) (adjust target size in MB as needed).
  • Verify no open transactions are holding the log active by checking sys.dm_tran_active_transactions.

Step 2: Switch Database to Simple Recovery Temporarily

  • Open SQL Server Management Studio (SSMS) or run via T-SQL: ALTER DATABASE [YourDB] SET RECOVERY SIMPLE;
  • This truncates the inactive portion of the log immediately, reducing overall log file size before export.
  • Re-run DBCC SHRINKFILE after switching recovery models to reclaim unused space.
  • Once shrink is complete, switch back to Full recovery if required for production use: ALTER DATABASE [YourDB] SET RECOVERY FULL;

Step 3: Scale Up the Target Azure SQL Service Tier

  • Navigate to the Azure Portal > SQL Databases > [Your Target Database] > Compute + Storage.
  • Increase the Service Tier (e.g., from Standard S3 to Premium P2, or increase vCores in General Purpose/Business Critical tiers) since max log size scales with DTUs/vCores.
  • Confirm the new maximum log size limit matches or exceeds your source log file size (reference Microsoft’s DTU/vCore log size documentation table).
  • Retry the restore or import operation using New-AzSqlDatabaseImport (PowerShell) or the Azure Portal Import wizard.

Step 4: Use BACPAC Export/Import Instead of Native Restore

  • If native .bak restore continues to fail, export the source database as a .bacpac file using SqlPackage.exe: SqlPackage.exe /Action:Export /SourceServerName:localhost /SourceDatabaseName:YourDB /TargetFile:C:\Export\YourDB.bacpac
  • Import the .bacpac into Azure SQL via SqlPackage.exe /Action:Import or the Azure Portal, which rebuilds the log file fresh rather than copying the oversized log structure.

Alternative or Verification Steps

  • Verify the fix by checking log file size post-restore in Azure SQL using DBCC SQLPERF(LOGSPACE) — it should display a size within the tier’s documented limit.
  • If scaling up the tier is not cost-feasible, consider migrating to Azure SQL Managed Instance, which supports larger native log file sizes and full .bak restore compatibility without the DTU-based cap.

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

Troubleshooting Guide: Error 1134 – Database Restore Exceeds Max Allowed Data File Size on Azure SQL

Why This Error Happens

This error occurs because Azure SQL Database enforces a maximum data file size limit based on the service tier and compute size (DTU or vCore) selected for the target database. When restoring a database backup from an on-premises SQL Server 2025 instance or another Azure SQL environment, the source data file(s) may exceed the capacity allocated to the destination database’s current pricing tier. SQL Server rejects the restore operation outright rather than truncating or failing mid-process, since there is no way to partially fit the data file within the allocated storage boundary.

Step-by-Step Resolution Guide

Step 1: Identify the Current Data File Size and Target Tier Limit

  • Run RESTORE FILELISTONLY FROM DISK = 'C:\Backups\YourDatabase.bak' to check the exact size of each data file in the backup.
  • Compare this size against the maximum storage limit of your current Azure SQL service tier (e.g., Basic = 2 GB, Standard = up to 1 TB, Premium/Business Critical = up to 4 TB).
  • Note the %d MB value reported in Error 1134, as this reflects the exact ceiling imposed by your current configuration.

Step 2: Scale Up the Azure SQL Database Tier or Compute Size

  • Navigate to the Azure Portal, select your SQL Database resource, and go to Settings > Compute + Storage.
  • Increase the Max Data Size slider or switch to a higher service tier (e.g., move from Standard S3 to Premium P2) that supports your required storage capacity.
  • Apply the changes and wait for the scaling operation to complete, which Azure reports under Activity Log.
  • Alternatively, run the following T-SQL command on the master database: ALTER DATABASE YourDatabaseName MODIFY (MAXSIZE = 500GB).

Step 3: Shrink or Clean Up the Source Database Before Backup

  • On the source SQL Server 2025 instance, run DBCC SHRINKFILE (YourDataFileName, TargetSizeMB) to reduce unused allocated space.
  • Remove unnecessary historical data, archived tables, or unused indexes that inflate the data file size unnecessarily.
  • Rebuild indexes after shrinking using ALTER INDEX ALL ON YourTableName REBUILD to avoid fragmentation issues introduced by the shrink operation.

Step 4: Retry the Restore Operation

  • Use the Azure Portal Import Database feature or run RESTORE DATABASE YourDatabaseName FROM DISK = 'C:\Backups\YourDatabase.bak' WITH MOVE on the updated tier.
  • Monitor progress through SQL Server Management Studio (SSMS) or the Azure Activity Log to confirm the restore completes without triggering Error 1134 again.

Alternative or Verification Steps

  • Verify success by querying sys.database_files on the restored database to confirm the file sizes fall within the new tier’s maximum allowed limit.
  • If scaling is not a viable option, consider splitting the database into smaller filegroups or migrating to Azure SQL Managed Instance, which supports significantly larger data file sizes compared to single Azure SQL databases.

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

Troubleshooting Guide: Error 1133 – Managed Instance Storage Limit Exceeded

Why This Error Happens

This error occurs when the total data and log file usage on a SQL Server 2025 managed instance reaches or exceeds the maximum storage size allocated to its service tier. It is typically triggered by unchecked transaction log growth, accumulation of old backup files within the instance’s storage allocation, or simply outgrowing the provisioned storage due to organic data growth. Unlike a disk-level “out of space” error, this is a soft limit enforced by SQL Server itself based on the instance’s configured storage ceiling, not necessarily the underlying physical disk capacity.

Step-by-Step Resolution Guide

Step 1: Identify Current Storage Consumption

  • Connect to the managed instance via SQL Server Management Studio (SSMS) or Azure Data Studio.
  • Run the following query to check database-level space usage:
  EXEC sp_spaceused;
  • Review sys.database_files and sys.master_files to identify which databases or log files are consuming the most space:
  SELECT DB_NAME(database_id) AS DBName, type_desc, size/128.0 AS SizeMB
  FROM sys.master_files
  ORDER BY SizeMB DESC;

Step 2: Reclaim Space from Transaction Logs and Temp Files

  • Check the recovery model of large databases; if set to FULL, ensure log backups are running on a regular schedule.
  • Shrink oversized transaction log files (only after a proper log backup) using:
  DBCC SHRINKFILE (N'LogFileName', target_size_MB);
  • Clear unnecessary TempDB bloat by restarting the TempDB service or manually shrinking TempDB files during a maintenance window.

Step 3: Remove Obsolete Backups and Unused Objects

  • Navigate to the backup storage path (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup\ on Windows Server 2025) and delete or archive backups older than your retention policy.
  • Drop unused databases, orphaned snapshots, or stale replicated copies that are no longer needed:
  DROP DATABASE [OldDatabaseName];
  • Run DBCC CLEANTABLE on tables with dropped sparse columns to reclaim additional space.

Step 4: Scale the Managed Instance Storage Tier

  • If cleanup does not resolve the issue, open the SQL Server Configuration Manager or the managed instance portal (depending on deployment type) and navigate to the Compute + Storage settings.
  • Increase the allocated storage size (%d MB limit referenced in the error) to the next available tier.
  • Apply the change and allow the instance to restart during the next maintenance window if required.

Step 5: Enable Storage Alerts for Future Prevention

  • Configure a SQL Server Agent Alert on Error 1133 so administrators are notified before the hard limit is hit again.
  • Set a threshold-based monitoring alert (e.g., at 85% storage utilization) using Performance Monitor counters or Extended Events.

Alternative or Verification Steps

  • Verify the fix by re-running sp_spaceused and confirming the instance’s current storage usage is now below the configured MB limit; attempt the previously failing write operation (e.g., an INSERT or backup job) to confirm it completes successfully.
  • As an alternative, if scaling storage is not immediately possible, offload cold data to an external Azure Blob Storage-backed external table or archive database to free up space on the primary instance.

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

Troubleshooting Guide: Error 1132 – Elastic Pool Storage Limit Exceeded

Why This Error Happens

This error occurs when the combined data storage consumed by all databases within an Azure SQL Elastic Pool (or a SQL Server 2025 instance configured with elastic pool semantics) exceeds the maximum storage threshold defined for that pool’s service tier. This is typically caused by unmonitored data growth, large transaction log files not being truncated, or a misconfigured pool size that does not match the actual workload requirements. Additionally, temporary spikes from bulk insert operations, index rebuilds, or orphaned data files can push the pool past its provisioned MB limit before autogrowth settings or tier upgrades are applied.

Step-by-Step Resolution Guide

Step 1: Identify Current Storage Consumption

  • Open SQL Server Management Studio (SSMS) and connect to the instance hosting the elastic pool.
  • Run the following query to check per-database space usage:
  SELECT DB_NAME(database_id) AS DatabaseName, 
         SUM(size) * 8 / 1024 AS SizeMB
  FROM sys.master_files
  GROUP BY database_id
  ORDER BY SizeMB DESC;
  • Cross-reference results against the Azure Portal under SQL elastic pools > [Pool Name] > Overview > Storage Used.

Step 2: Clear Unnecessary Data and Reclaim Space

  • Navigate to Database > Tasks > Shrink > Database in SSMS for the largest offending database.
  • Alternatively, run DBCC SHRINKDATABASE (YourDatabaseName, 10); to reclaim unused allocated space.
  • Check for bloated transaction logs using DBCC SQLPERF(LOGSPACE); and switch recovery model to Simple temporarily if logs are the culprit.

Step 3: Increase the Elastic Pool Storage Limit

  • Go to the Azure Portal (or Windows Admin Center if managing locally via Windows Server 2025) and select the affected Elastic Pool.
  • Under Configure, increase the Max Storage (MBs) slider to a value higher than current usage, or upgrade the service tier (e.g., Standard to Premium) to unlock higher storage ceilings.
  • Click Save and allow 5–10 minutes for the scaling operation to propagate across all pooled databases.

Step 4: Redistribute Databases Across Pools

  • If storage limits are a tier-wide constraint, open Elastic Pool Manager and move lower-priority databases to a separate pool with its own storage allocation.
  • Use ALTER DATABASE [DBName] MODIFY (SERVICE_OBJECTIVE = ELASTIC_POOL(name = [NewPoolName])); to migrate a database out of the saturated pool.

Alternative or Verification Steps

  • Re-run the SUM(size) query from Step 1 and confirm the total is now below the new MB threshold shown in the Azure Portal overview pane.
  • If the error persists immediately after resizing, restart the SQL Server service (Restart-Service MSSQLSERVER in PowerShell) to force the engine to re-read the updated pool configuration.

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

Troubleshooting Guide: SQL Server Error 1131 — Failed to Truncate AppendOnlyStorageUnit

Why This Error Happens

This message is generated by the In-Memory OLTP (Hekaton) engine when it attempts to truncate an internal AppendOnlyStorageUnit checkpoint file unit but cannot do so because the unit is still referenced by an active transaction or a long-running scan. This commonly occurs under heavy write workloads where checkpoint file merge/truncation operations fall behind due to disk I/O latency, insufficient memory for the in-memory OLTP engine, or antivirus/backup software holding a lock on the database’s data files. Since SQL Server automatically retries this operation on the next checkpoint cycle, the error is almost always benign and self-resolving, but persistent occurrences indicate an underlying storage performance or resource contention issue.

Step-by-Step Resolution Guide

Step 1: Confirm the Severity and Frequency of the Message

  • Open the SQL Server Error Log via SSMS: Management > SQL Server Logs, or query sys.dm_os_ring_buffers for recurring Error 1131 entries.
  • Check if the message appears once (informational, safe to ignore) or repeatedly over several hours (indicates a blocking issue).
  • Run SELECT * FROM sys.dm_db_xtp_checkpoint_files WHERE database_id = DB_ID('YourDbName'); to inspect pending checkpoint file states.

Step 2: Identify Long-Running Transactions Blocking Truncation

  • Execute SELECT * FROM sys.dm_tran_active_transactions; and SELECT * FROM sys.dm_db_xtp_transactions; to find transactions holding references to the AppendOnlyStorageUnit.
  • Look for open transactions with unusually high elapsed_time_seconds values.
  • Terminate or allow completion of any orphaned sessions using KILL <session_id>; after confirming it is safe to do so.

Step 3: Rule Out Disk I/O and Antivirus Interference

  • Navigate to the data file directory (default: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\) and confirm the drive hosting the memory-optimized filegroup has adequate free space and low I/O latency.
  • Add an exclusion rule in Windows Defender or third-party antivirus for the .ndf memory-optimized container files and the DATA folder to prevent file-lock conflicts.
  • Check Performance Monitor (perfmon.exe) counters under “SQL Server: XTP Checkpoint Files” for signs of I/O bottlenecks.

Step 4: Force a Manual Checkpoint and Merge

  • Run CHECKPOINT; manually against the affected database to trigger an immediate retry of the truncation process.
  • If merge requests are stuck, query sys.dm_db_xtp_merge_requests to check pending merge operations and manually request one using EXEC sys.sp_xtp_checkpoint_force_garbage_collection @database_name = 'YourDbName'; (SQL Server 2025 supports this extended procedure for forcing cleanup).

Step 5: Allocate Additional Memory Resources for In-Memory OLTP

  • Open SQL Server Configuration Manager and verify the “Max Server Memory” setting under Server Properties > Memory is not constraining the Hekaton engine.
  • Increase available RAM or adjust the max server memory (MB) configuration value using sp_configure if the server is memory-starved.

Alternative or Verification Steps

  • Verify the fix by monitoring the SQL Server Error Log for 24–48 hours to confirm Error 1131 no longer recurs; the absence of repeated entries confirms the checkpoint file truncation is now completing successfully on retry.
  • If the issue persists, rebuild the memory-optimized filegroup container by running DBCC CHECKDB and consider migrating the memory-optimized data to a faster SSD-backed storage tier to eliminate I/O-induced truncation failures.

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

Why This Error Happens

Error 1130 occurs when SQL Server 2025 attempts to allocate a new extent for a worktable in tempdb but encounters corruption or inconsistency in the allocation bitmap pages (GAM/SGAM/PFS). This typically happens due to insufficient disk space on the tempdb volume, abrupt shutdowns that leave tempdb in an inconsistent state, or underlying storage/file system corruption on Windows Server 2025. Since tempdb is recreated at every SQL Server service restart, this error often points to a deeper issue with disk I/O, antivirus interference, or an undersized tempdb configuration causing contention during heavy query workloads.

Step-by-Step Resolution Guide

Step 1: Verify Disk Space and I/O Health on the Tempdb Volume

  • Check the drive hosting tempdb (e.g., T:\SQLData\tempdb.mdf) has at least 20% free space.
  • Run chkdsk T: /f /r in an elevated Command Prompt to scan for file system errors.
  • Review Windows Event Viewer under Windows Logs > System for Disk or NTFS warning entries correlating with the SQL Server error timestamp.

Step 2: Restart SQL Server to Rebuild Tempdb

  • Open SQL Server Configuration Manager and restart the SQL Server (MSSQLSERVER) service; this forces tempdb to be recreated cleanly.
  • Alternatively, run from an elevated PowerShell session: Restart-Service -Name "MSSQLSERVER" -Force
  • Confirm tempdb rebuilds without errors by checking the SQL Server Error Log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.

Step 3: Run DBCC CHECKDB Against Tempdb

  • Execute DBCC CHECKDB (tempdb) WITH NO_INFOMSGS, ALL_ERRORMSGS; in SQL Server Management Studio (SSMS).
  • Review output for allocation errors referencing GAM, SGAM, or PFS pages.
  • If corruption is confirmed, proceed to rebuild tempdb manually using ALTER DATABASE tempdb MODIFY FILE to reset file paths and sizes, then restart the service.

Step 4: Exclude Tempdb Files from Antivirus Scanning

  • Open Windows Security > Virus & threat protection > Exclusions on Windows Server 2025.
  • Add the tempdb directory (e.g., T:\SQLData\) as an exclusion to prevent file-locking conflicts during extent allocation.
  • Restart the SQL Server service after applying the exclusion.

Step 5: Increase Tempdb File Size and Add Data Files

  • In SSMS, navigate to tempdb > Properties > Files and increase initial file size to reduce autogrowth events (e.g., set to 2048 MB).
  • Add multiple tempdb data files (one per logical CPU core, up to 8) using ALTER DATABASE tempdb ADD FILE to reduce allocation contention.
  • Set autogrowth to a fixed MB increment (e.g., 512 MB) rather than a percentage to avoid unpredictable extent allocation delays.

Alternative or Verification Steps

  • After applying fixes, run a stress test using SELECT * INTO #TempTable FROM sys.objects CROSS JOIN sys.objects; repeatedly under load to confirm no Error 1130 recurs in the Error Log.
  • If the issue persists, consider moving tempdb to a dedicated high-performance SSD volume and verify NTFS allocation unit size is set to 64 KB during formatting for optimal SQL Server I/O alignment.

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

Troubleshooting Guide: SQL Server Error 1129 — Deferred Deallocation Cleanup Failure

Why This Error Happens

This error occurs when SQL Server 2025 attempts to clean up deferred deallocations (pages marked for removal after a large delete or drop operation) but cannot access or write to the target filegroup. The root cause is typically a filegroup marked as read-only, insufficient disk space to complete the deallocation transaction, or underlying file corruption preventing the Storage Engine from updating allocation metadata (PFS/GAM/SGAM pages). In some cases, this is also triggered by an abrupt service termination or I/O subsystem failure that left the database in an inconsistent state regarding pending deallocations.

Step-by-Step Resolution Guide

Step 1: Verify Filegroup and Database State

  • Open SQL Server Management Studio (SSMS) or a query window and run: SELECT name, state_desc, is_read_only FROM sys.databases WHERE name = 'YourDatabaseName';
  • Confirm the database is not stuck in RECOVERY_PENDING, SUSPECT, or EMERGENCY mode.
  • Check filegroup read-only status with: SELECT name, is_read_only FROM sys.filegroups;

Step 2: Check and Free Up Disk Space

  • Navigate to the physical data file location (commonly C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\) and confirm the host volume has at least 15-20% free space.
  • If space is low, either expand the virtual disk in Windows Server 2025’s Disk Management console or move secondary data files to a new volume using ALTER DATABASE ... MODIFY FILE.
  • Delete unnecessary log backups or old .bak files cluttering the storage array if space is critically low.

Step 3: Set Filegroup to Read-Write (If Applicable)

  • If the filegroup was intentionally or accidentally set to read-only, toggle it back using: ALTER DATABASE YourDatabaseName MODIFY FILEGROUP YourFileGroupName READWRITE;
  • Re-run the operation that originally triggered the deferred deallocation (e.g., a large DELETE or DROP TABLE statement) to allow SQL Server to retry the cleanup.

Step 4: Run DBCC CHECKDB to Rule Out Corruption

  • Execute DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to scan for allocation or consistency errors.
  • If corruption is found in system pages (PFS/GAM/SGAM), review the suggested REPAIR_ALLOW_DATA_LOSS option only as a last resort, and only after taking a full backup.

Step 5: Restart the SQL Server Service to Clear Pending Transactions

  • Open Services.msc on Windows Server 2025 / Windows 11, locate SQL Server (MSSQLSERVER), and restart the service to force a clean recovery cycle.
  • Alternatively, use PowerShell: Restart-Service -Name 'MSSQLSERVER' -Force

Alternative or Verification Steps

  • After applying fixes, verify success by re-running the failed deletion/drop operation and checking the SQL Server Error Log (via EXEC sp_readerrorlog;) to confirm Error 1129 no longer appears.
  • If the issue persists, restore the affected database from the most recent clean backup to a test instance and compare filegroup configurations to isolate whether the problem is environmental (disk/OS) or data-specific (corruption).

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

Troubleshooting Guide: SQL Server Error 1128 – “Table Error: Page (%d:%d)”

Why This Error Happens

Error 1128 occurs when SQL Server’s storage engine detects an inconsistency in the page allocation structure of a table, typically indicating that a page is incorrectly allocated, shared, or referenced by multiple objects simultaneously. This is most commonly caused by physical disk corruption, improper shutdowns, faulty storage drivers, or hardware-level I/O failures that corrupt the database’s internal allocation metadata (IAM/PFS pages). In rare cases, it can also stem from bugs in third-party backup/restore tools that manipulate database files while SQL Server has them offline.

Step-by-Step Resolution Guide

Step 1: Run DBCC CHECKDB to Confirm the Scope of Corruption

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Execute: DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output to identify all affected object IDs and page numbers tied to Error 1128.
  • Note whether the corruption is isolated to a single table/index or spans multiple objects.

Step 2: Check the Windows Event Viewer and Disk Health

  • Navigate to Event Viewer > Windows Logs > System on Windows Server 2025 / Windows 11.
  • Look for Disk, NTFS, or Storage-related warnings (Event IDs 7, 11, 51) around the time the error first appeared.
  • Run chkdsk C: /f /r (replace with the correct volume) via an elevated Command Prompt, then schedule a restart if prompted.
  • Verify that the storage controller drivers are up to date via Device Manager or the manufacturer’s support site.

Step 3: Restore from a Clean Backup (Preferred Fix)

  • Take the database offline temporarily: ALTER DATABASE YourDatabaseName SET OFFLINE WITH ROLLBACK IMMEDIATE;
  • Restore the most recent verified-clean full backup, followed by any differential/log backups:
    RESTORE DATABASE YourDatabaseName FROM DISK = 'D:\Backups\YourDatabaseName.bak' WITH REPLACE, RECOVERY;
  • Confirm the backup predates the corruption event by cross-referencing timestamps in the SQL Server error log.

Step 4: Use Emergency Repair Only as a Last Resort

  • If no clean backup exists, set the database to EMERGENCY mode:
    ALTER DATABASE YourDatabaseName SET EMERGENCY;
  • Run: DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS;
  • Immediately back up the database afterward, as this operation can delete corrupted pages/rows permanently.

Alternative or Verification Steps

  • After applying a fix, re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm zero allocation or consistency errors are returned.
  • If corruption recurs on the same LUN/volume, move the database files to a different physical disk or storage array and run extended hardware diagnostics (e.g., Storage Spaces Direct health checks or vendor RAID utilities) to rule out failing hardware.

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

Troubleshooting Guide: SQL Server Error 1127

Why This Error Happens

Error 1127 indicates physical database corruption, specifically an internal page linkage inconsistency detected by DBCC CHECKDB during an allocation or structure consistency check. This typically occurs due to faulty disk I/O subsystems, unexpected server shutdowns, failing storage hardware, or bit-level corruption introduced by antivirus software or a misbehaving storage driver. In nearly all cases, the underlying data file (.mdf/.ndf) has sustained physical damage that SQL Server’s internal consistency checks have flagged as a page linkage mismatch.

Step-by-Step Resolution Guide

Step 1: Isolate and Confirm the Corruption Scope

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; from SQL Server Management Studio (SSMS) or sqlcmd.
  • Note the exact Page ID (%S_PGID) and object/index ID referenced in the error output.
  • Check the SQL Server Error Log (default path: C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) for correlating I/O or disk warnings (Event ID 823/824).

Step 2: Check the Underlying Storage Hardware

  • Open Windows Server 2025 Event Viewer and inspect the System log for Disk or NTFS warnings around the time of corruption.
  • Run chkdsk C:\ /f /r (replace with the correct drive hosting your data files) during a maintenance window to repair file system-level issues.
  • Verify that antivirus or endpoint protection software has exclusions configured for the SQL Server data directory (typically C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA\).

Step 3: Restore from a Known-Good Backup (Preferred Fix)

  • Take a tail-log backup if the database is still in a usable state: BACKUP LOG YourDatabaseName TO DISK = 'D:\Backups\YourDB_tail.trn';
  • Restore the last clean full backup plus subsequent log/differential backups using RESTORE DATABASE YourDatabaseName FROM DISK = '...' WITH NORECOVERY, chaining logs until fully recovered.
  • Bring the database online with RESTORE DATABASE YourDatabaseName WITH RECOVERY;.

Step 4: Use DBCC CHECKDB Repair as a Last Resort

  • Set the database to single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS); — note this may delete corrupted rows/pages to resolve linkage errors.
  • Revert to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 5: Rebuild Affected Indexes

  • After repair or restore, rebuild all indexes on the affected table using ALTER INDEX ALL ON YourTable REBUILD;.
  • This clears any residual page-pointer inconsistencies not fully resolved by the repair operation.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm zero allocation or consistency errors are returned.
  • If corruption recurs on the same disk/LUN after remediation, treat it as a hardware-level issue and migrate the database files to new storage, then run DBCC CHECKDB again to confirm stability.

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

Troubleshooting Guide: Error 1126 — Table Error, Page %S_PGID, Test Failed, Slot %d

Why This Error Happens

Error 1126 occurs when SQL Server’s DBCC consistency checker detects that a page-level structure test has failed on a specific slot within a database page, indicating physical or logical corruption. This is typically caused by underlying storage issues such as faulty disk sectors, improper shutdowns, SAN/storage controller firmware bugs, or corruption introduced during I/O operations (bit flips, torn pages) that bypassed SQL Server’s page checksum protections. It can also surface after an unclean failover in an Always On Availability Group or after restoring a backup that was already corrupted at the source.

Step-by-Step Resolution Guide

Step 1: Confirm the Scope of Corruption

  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; to get the full list of affected objects, pages, and slots.
  • Check the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) and Windows Event Viewer (Application log) for correlating I/O or disk warnings (Event ID 823, 824, or 825).
  • Note the exact table, index, and page ID (%S_PGID) referenced in the error to determine if corruption is isolated to a non-clustered index (easier fix) or clustered data (harder fix).

Step 2: Rule Out and Fix Underlying Hardware/Storage Issues

  • Run chkdsk D:\ /f /r (replace D:\ with your actual SQL data drive) to scan for and repair physical disk errors.
  • Check Windows Server 2025 Storage Spaces or SAN management console for any reported virtual disk health alerts.
  • Verify disk firmware and HBA/RAID controller drivers are up to date, as outdated drivers are a common cause of torn-page writes.

Step 3: Restore From a Clean Backup (Preferred Method)

  • Identify the last known good full backup taken before the corruption timestamp using RESTORE HEADERONLY FROM DISK = 'E:\Backups\YourDB.bak';
  • Perform a restore with recovery: RESTORE DATABASE YourDatabaseName FROM DISK = 'E:\Backups\YourDB.bak' WITH REPLACE, RECOVERY;
  • Apply any subsequent transaction log backups in sequence to minimize data loss up to the point of failure.

Step 4: Use DBCC CHECKDB Repair as a Last Resort

  • Put the database in single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; — understand this may delete the corrupted rows/pages entirely.
  • Return the database to multi-user mode: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Step 5: Rebuild Affected Indexes

  • If corruption was isolated to a non-clustered index, drop and rebuild it instead of running a destructive repair: ALTER INDEX ALL ON YourTableName REBUILD;
  • This avoids data loss since non-clustered indexes can be fully regenerated from the clustered index/heap.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; after remediation — a clean run with zero allocation or consistency errors confirms the fix.
  • If corruption recurs after repair, engage your storage/hardware vendor for diagnostics, as repeated Error 1126 strongly indicates a persistent hardware-level fault rather than a SQL Server defect.

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

Troubleshooting Guide: SQL Server Error 1125 – Table Error Test Failed

Why This Error Happens

Error 1125 occurs when SQL Server’s consistency checker detects that a data or index page has failed internal structural validation, typically caused by physical corruption on the disk subsystem. This can result from faulty storage hardware, improper shutdowns, bit-flips caused by failing RAM, or file system corruption on the underlying NTFS volume. Antivirus or backup software interfering with the MDF/LDF files while SQL Server has them open can also trigger this inconsistency.

Step-by-Step Resolution Guide

Step 1: Identify the Scope of Corruption

  • Open SQL Server Management Studio (SSMS) and run DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Note the specific Page ID (%S_PGID) and Slot number referenced in the error to determine if it is a single table or a system-wide issue.
  • Check the Windows Event Viewer (Application and System logs) for underlying disk I/O errors (Event ID 7, 9, or 15) that may correlate with the SQL error.

Step 2: Verify Hardware and Storage Integrity

  • Run chkdsk C: /f /r (replace C: with your data drive) via an elevated Command Prompt on Windows Server 2025 to scan for and repair file system errors.
  • Check the Storage Spaces Direct (S2D) health status if running on a clustered environment using Get-VirtualDisk in PowerShell.
  • Ensure SQL Server data files are excluded from real-time antivirus scanning via Windows Defender settings to prevent file locking conflicts.

Step 3: Restore from a Known Good Backup

  • Navigate to your backup repository and verify the latest .bak file integrity using RESTORE VERIFYONLY FROM DISK = 'D:\Backups\YourDB.bak';
  • Perform a restore to a new database name first to validate the data is clean before overwriting production: RESTORE DATABASE YourDB_Test FROM DISK = 'D:\Backups\YourDB.bak' WITH MOVE...
  • If backups are unavailable or outdated, proceed to repair the existing database directly.

Step 4: Execute Repair as a Last Resort

  • Place the database in single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run the repair command: DBCC CHECKDB('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
  • Revert the database to multi-user mode immediately after: ALTER DATABASE YourDatabaseName SET MULTI_USER;

Alternative or Verification Steps

  • Re-run DBCC CHECKDB with no repair options after the fix; a clean result with “0 allocation errors and 0 consistency errors” confirms the Page/Slot error is resolved.
  • If corruption persists after a storage check, consider migrating the database files to a different physical disk/LUN entirely, as this often indicates a failing physical drive rather than a software-level SQL issue.

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

Troubleshooting Guide: SQL Server Error 1124 – Table Error: Page %S_PGID Test Failed

Why This Error Happens

Error 1124 occurs when SQL Server’s consistency checker (DBCC CHECKDB) detects that a page structure on disk does not match the expected internal linkage, typically due to physical corruption of the database file. This corruption is most often caused by faulty disk I/O, storage controller errors, abrupt power loss, or a failing SSD/HDD sector that silently wrote bad data. It can also surface after improper VM snapshot restores or when antivirus software locks/modifies .mdf or .ndf files mid-write on Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Run Diagnostics

  • Open SQL Server Management Studio (SSMS) or sqlcmd and set the database to single-user mode: ALTER DATABASE [YourDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run a full consistency check: DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Record the exact Page ID (%S_PGID) and Slot number reported in the output for reference.

Step 2: Verify Underlying Storage Health

  • Check Windows Event Viewer under Windows Logs > System for Disk or Ntfs warnings (Event ID 7, 51, or 153) correlating with the SQL error timestamp.
  • Run chkdsk C: /f /r (or the relevant drive letter hosting the .mdf/.ldf files) via an elevated Command Prompt, scheduling a reboot if the volume is in use.
  • If using SAN/NAS storage, confirm there are no firmware or multipath driver alerts in Server Manager.

Step 3: Restore From a Clean Backup (Preferred Fix)

  • Navigate to your backup repository (e.g., D:\SQLBackups\YourDB.bak) and verify backup integrity: RESTORE VERIFYONLY FROM DISK = 'D:\SQLBackups\YourDB.bak';
  • Restore the database to a point before corruption occurred: RESTORE DATABASE [YourDB] FROM DISK = 'D:\SQLBackups\YourDB.bak' WITH REPLACE, RECOVERY;
  • If no clean backup exists, proceed to repair as a last resort: DBCC CHECKDB ('YourDB', REPAIR_ALLOW_DATA_LOSS); — note this may discard the corrupted row/page.

Step 4: Bring Database Back Online

  • Set the database back to multi-user mode: ALTER DATABASE [YourDB] SET MULTI_USER;
  • Monitor SQL Server error logs (C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG) for recurrence of Error 1124 over the next 24–48 hours.

Alternative or Verification Steps

  • Re-run DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS; immediately after the fix — a clean result with zero allocation/consistency errors confirms resolution.
  • If corruption recurs on the same physical page/slot, treat it as a hardware fault: migrate the database files to a different volume/disk and run full vendor diagnostics (e.g., manufacturer SSD toolbox) on the original drive.

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

Troubleshooting Guide: SQL Server Error 1123 – Unexpected Page Type

Why This Error Happens

Error 1123 occurs when SQL Server’s storage engine encounters a database page whose header type does not match what the allocation structures (PFS, GAM, or IAM) expect to find at that location. This is almost always caused by physical-level data corruption, typically resulting from faulty disk I/O, a failing storage controller, improper shutdowns, or unverified writes (Torn Page) during a power failure. In rare cases, it can also result from third-party backup or antivirus software directly modifying or locking the .mdf/.ndf files while SQL Server is writing to them.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Check Hardware Integrity

  • Immediately set the affected database to SINGLE_USER mode to prevent further writes that could compound the corruption.
  • Run the command: ALTER DATABASE [YourDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Check the Windows Event Viewer (Application and System logs) for underlying Disk, Controller, or NTFS warnings (Event ID 7, 9, or 51) that occurred around the time of the corruption.

Step 2: Run DBCC CHECKDB to Assess the Damage

  • Execute a full consistency check to identify the exact scope of the corruption and locate the specific Page IDs mentioned in the error.
  • Run the command: DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output to determine if the corruption is isolated to a single non-clustered index (repairable) or a clustered index/system table (requires restore).

Step 3: Restore From a Clean Backup (Preferred Method)

  • Since Error 1123 indicates physical corruption, restoring from the last known good full backup is the safest fix, as REPAIR_ALLOW_DATA_LOSS may delete the corrupted pages entirely.
  • Navigate to your backup directory (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup\) and verify the integrity of the .bak file using RESTORE VERIFYONLY.
  • Restore the database using: RESTORE DATABASE [YourDB] FROM DISK = 'PathToYourBackup.bak' WITH REPLACE, RECOVERY;

Step 4: Execute Repair as a Last Resort

  • If no valid backup exists, run the repair command, understanding that this will deallocate the corrupted page and any data on it will be lost.
  • Run the command: DBCC CHECKDB ('YourDB', REPAIR_ALLOW_DATA_LOSS);
  • Return the database to multi-user access once the command completes: ALTER DATABASE [YourDB] SET MULTI_USER;

Alternative or Verification Steps

  • Verify the Fix: Re-run DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS; one final time. If the command returns “0 allocation errors and 0 consistency errors,” the fix was successful.
  • Alternative Solution: If corruption recurs frequently on the same volume, run chkdsk /f /r on the underlying Windows Server 2025 volume during a maintenance window to rule out physical sector failure on the disk.

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

Troubleshooting Guide: Error 1122 – Page Alignment Failure in SQL Server 2025

Why This Error Happens

Error 1122 occurs when DBCC CHECKDB encounters a page structure where internal pointer addresses do not fall on proper byte-alignment boundaries, indicating physical corruption at the storage level. This is typically caused by faulty disk I/O subsystems, improper shutdowns, or storage drivers silently dropping writes (torn pages) before they reach the physical disk. In virtualized or SAN-backed environments running Windows Server 2025, this can also stem from misconfigured write-caching policies that violate SQL Server’s I/O guarantees.

Step-by-Step Resolution Guide

Step 1: Isolate the Database and Run Diagnostics

  • Place the affected database in single-user mode or take it offline for other connections to prevent further writes during diagnosis.
  • Run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS, DATA_PURITY; to confirm the scope of corruption.
  • Note the specific PageID (%SPGID) referenced in the error log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.

Step 2: Verify Hardware and Storage Integrity

  • Check the Windows Event Viewer under Windows Logs > System for Disk or NTFS warnings (Event ID 7 or 51) occurring around the same timestamp as the SQL error.
  • Run chkdsk C: /f /r (or the relevant drive letter hosting the .mdf/.ndf files) via an elevated Command Prompt to scan for and repair file system-level sector errors.
  • If using a SAN or virtual disk, verify that the storage controller cache is configured for “Write Through” rather than “Write Back” unless a Battery Backup Unit (BBU) is confirmed active.

Step 3: Restore from a Clean Backup

  • Since alignment errors usually indicate non-recoverable physical damage, the safest fix is restoring the specific database from the last known good backup.
  • Use RESTORE DATABASE [YourDatabaseName] FROM DISK = 'E:\Backups\LastGood.bak' WITH REPLACE, RECOVERY; to overwrite the corrupted file structure entirely.
  • Ensure the backup predates the first occurrence of the error in the logs to avoid restoring already-corrupted pages.

Step 4: Execute Repair as a Last Resort

  • If no valid backup exists, revert to single-user mode using ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;.
  • Run DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS); to force SQL Server to deallocate the corrupted page.
  • Be aware this action will result in the permanent loss of data contained within that specific page.

Alternative or Verification Steps

  • Verify the Fix: Re-run DBCC CHECKDB immediately after the restore or repair process completes; a clean result with “0 allocation errors and 0 consistency errors” confirms the fix was successful.
  • Alternative Check: If the error persists immediately after a restore, run the Windows Memory Diagnostic Tool (mdsched.exe), as faulty RAM on the host server can sometimes cause SQL Server to write misaligned data to disk even when the storage hardware itself is healthy.

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

Troubleshooting Guide: SQL Server Error 1119 – IAM Page Removal Failure

Why This Error Happens

Error 1119 occurs when SQL Server’s deallocation process attempts to remove an IAM (Index Allocation Map) page while another session, transaction, or background process still holds a lock on the parent object. This is typically triggered by concurrent DDL operations (such as TRUNCATE, DROP, or index rebuilds) running simultaneously with active transactions, replication processes, or backup operations on the same table. In rare cases, this can also indicate underlying allocation page corruption that is preventing SQL Server from cleanly resolving the lock state during deallocation.

Step-by-Step Resolution Guide

Step 1: Identify Blocking Sessions on the Object

  • Open SQL Server Management Studio (SSMS) and run sp_who2 or query sys.dm_exec_requests to find active sessions.
  • Execute the following to pinpoint blockers on the specific object:
SELECT request_session_id, resource_type, resource_description 
FROM sys.dm_tran_locks 
WHERE resource_database_id = DB_ID('YourDatabaseName');
  • Note the session_id values holding locks on the affected table or index.

Step 2: Terminate Conflicting Processes Safely

  • Confirm no critical transactions are in-flight using DBCC OPENTRAN before killing any session.
  • If a long-running or orphaned session is confirmed as the blocker, terminate it:
KILL <session_id>;
  • Retry the original operation (TRUNCATE/DROP/Index Rebuild) that triggered Error 1119.

Step 3: Check for Replication or CDC Interference

  • Navigate to SQL Server Management Studio > Replication > Local Publications to verify no active snapshot or log reader jobs are touching the table.
  • If using Change Data Capture (CDC), run sys.sp_cdc_disable_table temporarily on the affected table, perform the operation, then re-enable capture.

Step 4: Run Consistency Checks to Rule Out Corruption

  • Execute a full integrity check on the database:
DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output for allocation errors; if corruption is found, proceed with DBCC CHECKDB repair options or restore from a verified backup in C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Backup.

Alternative or Verification Steps

  • Re-run the original DDL statement (TRUNCATE/DROP) during a maintenance window with no active user connections to confirm the IAM page deallocates without error.
  • If the issue persists, restart the SQL Server service via Services.msc (Windows Server 2025) to clear any stale lock metadata, then re-attempt the operation immediately after the service comes back online.

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

Why This Error Happens

Error 1121 occurs when SQL Server’s space allocator is unable to find or reserve a page within a database’s data files, typically because the file has reached its maximum configured size or the disk volume itself is out of physical space. This can also happen when autogrowth is disabled or misconfigured, preventing the engine from expanding the file to satisfy the allocation request. In some cases, filesystem-level corruption or a mismatch between the database’s metadata (sysfiles) and actual file size on disk can trigger this error even when space appears available.

Step-by-Step Resolution Guide

Step 1: Verify Disk Space and File Growth Settings

  • Open SQL Server Management Studio (SSMS) and run EXEC sp_helpdb 'YourDatabaseName'; to check current file sizes and growth settings.
  • Check the underlying volume (e.g., D:\SQLData) in Windows File Explorer or via Get-PSDrive in PowerShell to confirm free space is available.
  • Look for files with “Restricted Growth” (MAXSIZE set to a fixed limit) — this is a common cause of Error 1121.

Step 2: Increase File Size Limits or Add a New Data File

  • If growth is restricted, run the following to remove the cap:
  ALTER DATABASE YourDatabaseName
  MODIFY FILE (NAME = YourLogicalFileName, MAXSIZE = UNLIMITED);
  • If the disk itself is full, add a secondary data file on a different volume:
  ALTER DATABASE YourDatabaseName
  ADD FILE (NAME = YourDB_Data2, FILENAME = 'E:\SQLData\YourDB_Data2.ndf', SIZE = 500MB, FILEGROWTH = 100MB);
  • Ensure the SQL Server service account has write permissions to the new path (check via icacls "E:\SQLData").

Step 3: Check for TempDB or Log File Exhaustion

  • If the error references TempDB specifically, confirm TempDB files aren’t capped and have sufficient autogrowth increments (avoid percentage-based growth; use fixed MB values instead).
  • Run DBCC SQLPERF(LOGSPACE); to rule out transaction log space issues contributing to allocation failures.

Step 4: Run Consistency Checks

  • Execute DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORS; to rule out underlying corruption in the allocation pages (GAM/SGAM/PFS pages).
  • Review the SQL Server Error Log (Get-Content "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG" in PowerShell) for correlating disk I/O warnings around the same timestamp.

Alternative or Verification Steps

  • After applying fixes, rerun the operation that previously failed (e.g., bulk insert, index rebuild) and confirm no Error 1121 is raised in the Application Event Viewer or SQL Error Log.
  • If the issue persists despite available space, consider running DBCC SHRINKFILE followed by a manual regrowth, or restore the database from a known-good backup if GAM/SGAM corruption is confirmed via DBCC CHECKDB.

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

Troubleshooting Guide: SQL Server Error 1105 – Filegroup Full

Why This Error Happens

Error 1105 occurs when SQL Server cannot allocate additional space for an object because the target filegroup has exhausted its available storage. This typically happens when data files are set to a fixed maximum size, autogrowth is disabled, the underlying disk volume has run out of physical space, or the database has hit the 16TB limit imposed on individual files (even those marked UNLIMITED). It can also occur if files were created with restrictive MAXSIZE settings that no longer match the growth needs of the database.

Step-by-Step Resolution Guide

Step 1: Identify the Affected Filegroup and File Usage

  • Run the following query to check file size, used space, and growth settings:
  SELECT name, size, max_size, growth, is_percent_growth 
  FROM sys.database_files;
  • Confirm which filegroup is reported in the error message and cross-reference it with sys.filegroups and sys.database_files.
  • Check current disk space on the volume hosting the .mdf/.ndf files via File Explorer or Get-PSDrive in PowerShell.

Step 2: Expand or Add Data Files

  • If the disk has free space, manually increase the file size or MAXSIZE:
  ALTER DATABASE [YourDB] 
  MODIFY FILE (NAME = 'YourFile', MAXSIZE = UNLIMITED, FILEGROWTH = 512MB);
  • If the disk is full, add a new data file to the filegroup on a different volume (e.g., D:\SQLData\ or a new mounted volume):
  ALTER DATABASE [YourDB] 
  ADD FILE (NAME = 'YourFile2', FILENAME = 'E:\SQLData\YourFile2.ndf', SIZE = 5GB, FILEGROWTH = 1GB) 
  TO FILEGROUP [PRIMARY];
  • Remember: even with MAXSIZE = UNLIMITED, a single file cannot exceed 16TB — you must add additional files to continue growing beyond that cap.

Step 3: Free Up Space or Reorganize Data

  • Shrink unnecessary log/data files if excessive free space exists elsewhere (DBCC SHRINKFILE).
  • Archive or purge old data into a separate filegroup/database to reduce pressure on the primary filegroup.
  • Move non-critical tables/indexes to a new filegroup on a separate drive to redistribute I/O and storage load.

Step 4: Enable and Validate Autogrowth Settings

  • Ensure FILEGROWTH is set to a reasonable fixed value (not a tiny default) to avoid frequent fragmentation:
  ALTER DATABASE [YourDB] 
  MODIFY FILE (NAME = 'YourFile', FILEGROWTH = 1GB);
  • Avoid percentage-based growth on very large files, as it can cause unpredictable allocation spikes.

Alternative or Verification Steps

  • Re-run the original operation (insert/index rebuild/etc.) that triggered the 1105 error to confirm successful allocation.
  • If disk expansion isn’t possible, use Storage Spaces in Windows Server 2025 to extend the volume, or provision additional virtual disks and add them as new SQL Server data files in a different filegroup.

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

Troubleshooting Guide: SQL Server Error 1104 – Tempdb Out of Space During Spilling

Why This Error Happens

This error occurs when a query operation—such as a hash join, sort, or large aggregation—spills intermediate results into tempdb, but tempdb’s data files have exhausted their available disk space or configured maximum size. This is typically caused by poorly optimized queries processing excessive row counts, missing or outdated statistics causing bad execution plans, or tempdb files that are undersized/not configured to autogrow properly. It can also happen if long-running transactions or orphaned sessions are holding tempdb space that never gets released.

Step-by-Step Resolution Guide

Step 1: Check Current Tempdb Space Usage

  • Open SQL Server Management Studio (SSMS) and run: EXEC sp_spaceused against tempdb, or query sys.dm_db_file_space_usage.
  • Check the physical disk location (commonly D:\SQLData\tempdb\ or E:\TempDB\) in Windows Explorer or via Get-PSDrive in PowerShell to confirm actual free disk space.
  • Identify if tempdb files have hit a configured MAXSIZE limit using sys.master_files.

Step 2: Identify and Terminate the Offending Query

  • Run sys.dm_db_task_space_usage joined with sys.dm_exec_requests to find sessions consuming the most tempdb space.
  • Use EXEC sp_who2 or Activity Monitor in SSMS to locate long-running or spilling queries.
  • Kill the problematic session if safe to do so: KILL <session_id>.

Step 3: Expand or Reconfigure Tempdb Files

  • Navigate to SSMS > Databases > System Databases > tempdb > Properties > Files.
  • Increase the initial file size and set autogrowth in fixed MB increments (not percentage) to avoid fragmentation—recommended: 512MB or 1GB increments.
  • Alternatively, run:
    ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, SIZE = 8192MB, FILEGROWTH = 1024MB);
  • Add additional tempdb data files (one per CPU core, up to 8) stored across separate physical disks if I/O contention is also a factor.

Step 4: Optimize the Query Causing Excessive Spilling

  • Open the execution plan in SSMS and look for warnings labeled “Sort” or “Hash Match” with high spill warnings.
  • Rewrite the query to filter rows earlier (push WHERE clauses before joins) and avoid SELECT *.
  • Update statistics on involved tables: UPDATE STATISTICS <table_name> WITH FULLSCAN;
  • Consider adding appropriate indexes to reduce the row count being processed in memory.

Step 5: Free Up Disk Space on the Tempdb Drive

  • Delete unnecessary files, old backups, or logs from the volume hosting tempdb.
  • If space is chronically limited, move tempdb to a dedicated drive with more capacity using:
    ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = 'F:\TempDB\tempdb.mdf');
  • Restart the SQL Server service (via services.msc or Restart-Service MSSQLSERVER) for the file relocation to take effect.

Alternative or Verification Steps

  • Re-run the original query and monitor sys.dm_db_file_space_usage in real time to confirm tempdb no longer approaches capacity.
  • If the issue persists, enable Trace Flag 1117 and 1118 (via SQL Server Configuration Manager startup parameters) to ensure uniform tempdb file growth and reduce allocation contention across multiple tempdb files.

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

Troubleshooting Guide: SQL Server Error 1102 — IAM Page Mismatch

Why This Error Happens

Error 1102 occurs when SQL Server’s storage engine detects that an Index Allocation Map (IAM) page does not match the expected object ID or sequence ID it is tracking, indicating database corruption at the allocation level. This typically results from improper shutdowns, disk/storage subsystem failures, faulty I/O drivers, or corrupted database files caused by hardware memory errors. It can also surface after restoring a backup that was already inconsistent or when antivirus/backup software locks database files during active transactions.

Step-by-Step Resolution Guide

Step 1: Run Immediate Diagnostics with DBCC CHECKDB

  • Open SQL Server Management Studio (SSMS) or sqlcmd and connect to the affected instance.
  • Execute: DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output to confirm the exact object ID and page ID referenced in the error and identify the full scope of corruption.

Step 2: Check the Windows Event Logs and Storage Health

  • Open Event Viewer (eventvwr.msc) and navigate to Windows Logs > System and Application.
  • Look for disk-related warnings (Event ID 7, 9, 51) from the disk or Storage source around the same timestamp as Error 1102.
  • Run chkdsk C:\ /f /r (or the appropriate drive letter hosting your .mdf/.ldf files) during a scheduled reboot window to rule out physical disk errors.
  • Verify your storage controller firmware and drivers are up to date via Device Manager or the vendor’s management utility.

Step 3: Restore From a Clean Backup (Preferred Fix)

  • Take a tail-log backup if the database is still accessible: BACKUP LOG YourDatabaseName TO DISK = 'D:\Backups\YourDatabase_tail.trn' WITH NORECOVERY;
  • Restore the most recent known-good full backup along with subsequent log backups using SSMS Restore Database wizard or T-SQL RESTORE DATABASE ... WITH RECOVERY.
  • Confirm the backup predates the corruption event by cross-referencing backup history in msdb.dbo.backupset.

Step 4: Use DBCC CHECKDB Repair as a Last Resort

  • If no clean backup exists, set the database to single-user mode: ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
  • Run: DBCC CHECKDB ('YourDatabaseName', REPAIR_ALLOW_DATA_LOSS);
  • Switch back to multi-user mode afterward: ALTER DATABASE YourDatabaseName SET MULTI_USER;
  • Note that this option may result in data loss, so only use it when backups are unavailable or also corrupted.

Alternative or Verification Steps

  • After applying a fix, re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS; and confirm it returns zero allocation or consistency errors.
  • If corruption recurs frequently, enable CHECKSUM page verification (ALTER DATABASE YourDatabaseName SET PAGE_VERIFY CHECKSUM;) and schedule nightly DBCC CHECKDB jobs via SQL Server Agent to catch issues early.

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

Troubleshooting Guide: SQL Server Error 1101 – Could Not Allocate a New Page

Why This Error Happens

This error occurs when SQL Server attempts to write new data but cannot extend the database file because the filegroup has run out of allocatable space. This is typically caused by autogrowth being disabled, the underlying disk volume running out of physical storage, or the database/file size hitting a configured maximum size limit. Additionally, even filegroups marked as “UNLIMITED” are capped at a hard 16TB ceiling per file, which can trigger this error on very large databases.

Step-by-Step Resolution Guide

Step 1: Check Disk Space and File Growth Settings

  • Open SSMS and navigate to Database Properties > Files to check current size and autogrowth configuration.
  • Verify the physical disk hosting the .mdf/.ndf files has free space using Get-PSDrive in PowerShell or File Explorer on Windows Server 2025.
  • Run the following T-SQL to check space usage: EXEC sp_spaceused;

Step 2: Expand Existing Files or Enable Autogrowth

  • If autogrowth is disabled, enable it:
  ALTER DATABASE [YourDB] MODIFY FILE (NAME = 'YourLogicalFileName', FILEGROWTH = 512MB);
  • Manually increase file size if disk space allows:
  ALTER DATABASE [YourDB] MODIFY FILE (NAME = 'YourLogicalFileName', SIZE = 20GB);
  • Ensure MAXSIZE is not restricting growth; set it to UNLIMITED if appropriate.

Step 3: Add a New Data File to the Filegroup

  • If the volume is full and cannot be expanded, add a new .ndf file on a different drive with available space:
  ALTER DATABASE [YourDB] ADD FILE (NAME = 'YourDB_Data2', FILENAME = 'D:\SQLData\YourDB_Data2.ndf', SIZE = 10GB, FILEGROWTH = 512MB) TO FILEGROUP [PRIMARY];
  • Confirm the target drive (e.g., D:\SQLData\) exists and the SQL Server service account has write permissions.

Step 4: Check the 16TB File Size Limit

  • If the file is approaching 16TB, you cannot grow it further—add an additional file in the filegroup (per Step 3) to distribute data.
  • Consider implementing table partitioning or archiving old data to reduce single-file footprint.

Step 5: Clear Unnecessary Space (If No New Storage Available)

  • Run DBCC SHRINKFILE cautiously to reclaim unused space, but only as a temporary fix, not a long-term solution.
  • Delete or archive obsolete data, old backups, or logs occupying the same physical volume via Disk Cleanup or manual file management.

Alternative or Verification Steps

  • Verify the fix by re-running the failing transaction or query and confirming no Error 1101 appears in the SQL Server Error Log or Windows Event Viewer.
  • As an alternative, migrate the database to a volume with more capacity using ALTER DATABASE ... MODIFY FILE to a new path, or leverage Storage Spaces in Windows Server 2025 to extend the underlying volume dynamically.

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

Troubleshooting Guide: Error 1098 – “The specified event type(s) is/are not valid on the specified target object”

Why This Error Happens

This error typically occurs when SQL Server Event Notifications or extended event sessions attempt to bind an event type to an object (such as a database, queue, or server) that does not support that particular event category. It often results from a mismatch between the event type scope (DDL vs. DML vs. server-level events) and the target object specified in the CREATE EVENT NOTIFICATION or extended events DDL statement. In some cases, this is caused by deprecated event types carried over from legacy scripts that are no longer valid in SQL Server 2025’s updated event architecture, or by corrupted system metadata in the sys.event_notifications catalog.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Event Notification Definition Causing the Conflict

  • Run the following query to locate existing event notifications and their target objects:
  SELECT name, type_desc, parent_class_desc, is_broker_queue
  FROM sys.event_notifications;
  • Cross-reference the type_desc column against Microsoft’s official Event Notification Event Type mapping table for SQL Server 2025 to confirm the event is valid at that scope (SERVER, DATABASE, or OBJECT level).
  • Pay close attention to events like DDL_DATABASE_LEVEL_EVENTS being mistakenly applied at the SERVER scope, which is a common trigger for Error 1098.

Step 2: Correct the Scope Mismatch in the Event Notification Script

  • Drop the invalid event notification using:
  DROP EVENT NOTIFICATION [YourEventNotificationName] ON SERVER;

(or ON DATABASE depending on original scope)

  • Rewrite the CREATE EVENT NOTIFICATION statement, ensuring the event group matches the target object. For example, server-scoped audits require FOR SERVER_AUDIT_CHANGE_GROUP, not database-only DDL events.
  • Re-deploy the corrected script through SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your SQL Server 2025 instance.

Step 3: Validate Service Broker Configuration

  • Since Event Notifications rely on Service Broker, confirm Broker is enabled on the target database:
  SELECT is_broker_enabled FROM sys.databases WHERE name = 'YourDatabaseName';
  • If disabled, enable it with:
  ALTER DATABASE [YourDatabaseName] SET ENABLE_BROKER;
  • Restart the SQL Server service via services.msc on Windows Server 2025 or Windows 11 to clear any cached metadata locks related to Broker queues.

Step 4: Check for SSMS/Engine Version Compatibility Issues

  • Confirm you are running the latest Cumulative Update (CU) for SQL Server 2025, as early builds had known issues with newly introduced event type validations.
  • Navigate to Help > About in SSMS or run SELECT @@VERSION; to verify the build number matches Microsoft’s latest patch release.
  • Apply pending Windows Updates via Settings > Windows Update on Windows Server 2025/Windows 11, as .NET Framework dependencies affecting SQL Server’s XEvent engine are sometimes patched through OS updates.

Alternative or Verification Steps

  • To verify the fix, re-run the original CREATE EVENT NOTIFICATION script in a test database; a successful execution with no Error 1098 confirms the scope mismatch has been resolved.
  • As an alternative, use Extended Events (XEvents) instead of legacy Event Notifications, as XEvents in SQL Server 2025 provide more flexible and granular event targeting without the strict object-scope limitations causing this error.

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

Why This Error Happens

SQL Server Error 1099 occurs when a Transact-SQL statement includes an ON clause (typically used to specify a filegroup or partition scheme) in a context where the storage engine does not support it—most commonly during CREATE INDEX, ALTER TABLE, or CREATE TABLE operations involving partitioned views, merge replication triggers, or full-text indexing. This mismatch usually happens because the target object (such as a partitioned table or indexed view) has an incompatible partition scheme, or because the SQL script was generated for an older/newer version of SQL Server and uses syntax not fully compatible with SQL Server 2025’s updated parser. In some cases, this also surfaces when migrating legacy databases to Windows Server 2025, where outdated compatibility levels conflict with new engine validation rules.

Step-by-Step Resolution Guide

Step 1: Identify the Exact Statement Causing the Error

  • Open SQL Server Management Studio (SSMS) and locate the failing script in Activity Monitor or the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • Run the statement manually in a new query window to reproduce the error and confirm which ON clause (filegroup, partition scheme, or trigger) is triggering it.
  • Check if the statement involves CREATE INDEX ... ON [FileGroup], ALTER TABLE ... ON [PartitionScheme], or a merge replication trigger definition.

Step 2: Verify Partition Scheme and Filegroup Compatibility

  • Run sp_helpindex 'YourTableName' and sp_help 'YourTableName' to confirm whether the table uses a partition scheme.
  • Ensure the ON clause filegroup/partition scheme referenced in your script actually exists by querying:
  SELECT name FROM sys.filegroups;
  SELECT name FROM sys.partition_schemes;
  • If the object was migrated from an older SQL Server version, drop and recreate the index/constraint without the legacy ON clause, letting SQL Server 2025 assign the default filegroup.

Step 3: Check Database Compatibility Level

  • Open SSMS, right-click the database → Properties → Options, and confirm the Compatibility Level is set to SQL Server 2025 (170).
  • If it’s set to an older level (e.g., 130 or 140), update it using:
  ALTER DATABASE YourDatabase SET COMPATIBILITY_LEVEL = 170;
  • Re-run the failing script after updating compatibility level, as older levels can cause the parser to misinterpret ON clause context.

Step 4: Review Merge Replication or Full-Text Catalog Definitions

  • If the error originates from a replication trigger, run sp_helpmergearticle to inspect trigger definitions tied to the article.
  • Regenerate replication triggers using the Replication Monitor snap-in, ensuring no deprecated ON syntax remains in custom trigger scripts.
  • For full-text indexing issues, drop and recreate the full-text catalog using CREATE FULLTEXT CATALOG without specifying an invalid ON filegroup reference.

Alternative or Verification Steps

  • After applying changes, re-execute the original script in a test environment and confirm it completes without Error 1099; check Event Viewer → Windows Logs → Application on Windows Server 2025 for any residual SQL Server warnings.
  • If the issue persists, restore a recent database backup to a sandbox instance and compare schema definitions using sp_helptext to isolate the specific object with the invalid ON clause before reapplying changes to production.

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

Troubleshooting Guide: SQL Server Error 1097 — “Cannot use IF UPDATE within this CREATE TRIGGER statement”

Why This Error Happens

This error occurs because the IF UPDATE(column_name) clause is only valid within INSERT or UPDATE triggers, but the trigger in question was defined only for DELETE operations (or lacks the correct trigger event entirely). SQL Server 2025 parses the trigger body at creation time and rejects the UPDATE() function reference when the triggering event list does not include INSERT or UPDATE. This typically stems from a malformed CREATE TRIGGER statement where the FOR/AFTER clause and the trigger body logic are mismatched.

Step-by-Step Resolution Guide

Step 1: Review the CREATE TRIGGER Syntax

  • Open SQL Server Management Studio (SSMS) connected to your SQL Server 2025 instance.
  • Locate the trigger definition using sp_helptext 'YourTriggerName'; in a new query window.
  • Check the FOR or AFTER clause — confirm whether it lists INSERT, UPDATE, DELETE, or a combination.

Step 2: Correct the Trigger Event Declaration

  • Modify the trigger header to include the UPDATE (and/or INSERT) event if your logic depends on IF UPDATE(column_name).
  • Example corrected syntax:
  CREATE TRIGGER trg_CheckColumnUpdate
  ON dbo.YourTable
  AFTER INSERT, UPDATE
  AS
  BEGIN
      IF UPDATE(ColumnName)
      BEGIN
          -- your logic here
      END
  END
  • Remove IF UPDATE() entirely if the trigger is genuinely meant to fire only on DELETE, since UPDATE() has no meaning in that context.

Step 3: Drop and Recreate the Trigger

  • Run DROP TRIGGER dbo.trg_CheckColumnUpdate; to remove the broken object.
  • Re-execute the corrected CREATE TRIGGER script in a query window targeting the correct database context (USE YourDatabase; first).
  • Confirm no red squiggly/parse errors appear in SSMS before executing.

Step 4: Validate Permissions and Object Context

  • Ensure the executing login has ALTER permission on the target table (db_ddladmin role or higher).
  • Check that the trigger is being created against a table object, not a view, since IF UPDATE() behaves differently (or is unsupported) on INSTEAD OF triggers over views in certain configurations.

Alternative or Verification Steps

  • Verify the fix by running a test UPDATE statement against the table and confirming the trigger logic executes without raising Error 1097 in the Messages pane.
  • If the issue persists, use sys.triggers and sys.trigger_events system views to cross-check that the type_desc for your trigger correctly lists UPDATE as an event:
  SELECT t.name, te.type_desc 
  FROM sys.triggers t 
  JOIN sys.trigger_events te ON t.object_id = te.object_id;

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

Why This Error Happens

Error 1096 occurs when a CLR stored procedure, function, or trigger is registered with a default value assigned to a parameter whose type is a CLR user-defined type (UDT) or a CLR table type. SQL Server’s T-SQL parser does not support binding default literal values to CLR-type parameters because the CLR type’s serialization format cannot be resolved into a constant at metadata-creation time. This typically surfaces after an assembly deployment or a database migration where the DDL script for the CLR routine was auto-generated with DEFAULT clauses that were valid for scalar types but not for custom CLR types.

Step-by-Step Resolution Guide

Step 1: Identify the Offending CLR Routine

  • Open SQL Server Management Studio (SSMS) and run the failing deployment script in isolation to capture the exact line number referenced in the Error 1096 message.
  • Query sys.assembly_modules and sys.parameters to locate any parameter where system_type_id = 240 (CLR UDT) and has_default_value = 1.
  • Example query:
  SELECT o.name, p.name AS param_name, p.has_default_value
  FROM sys.parameters p
  JOIN sys.objects o ON p.object_id = o.object_id
  WHERE p.system_type_id = 240 AND p.has_default_value = 1;

Step 2: Remove or Rewrite the Default Parameter Declaration

  • Edit the CREATE PROCEDURE / CREATE FUNCTION definition and strip out the DEFAULT clause tied to the CLR-typed parameter.
  • If a default behavior is required, handle the “no value supplied” logic inside the CLR C#/VB.NET code itself (e.g., check SqlContext.Pipe or use method overloading in the assembly) rather than in the T-SQL signature.
  • Re-deploy the modified assembly using ALTER ASSEMBLY or re-run CREATE ASSEMBLY FROM 'C:\SQLAssemblies\YourAssembly.dll' after rebuilding.

Step 3: Rebuild and Redeploy the Assembly

  • In Visual Studio (or csc.exe), rebuild the CLR project targeting .NET Framework/CLR version supported by SQL Server 2025.
  • Drop and recreate the procedure/function referencing the assembly:
  DROP PROCEDURE IF EXISTS dbo.YourCLRProc;
  CREATE PROCEDURE dbo.YourCLRProc (@param MyClrType)
  AS EXTERNAL NAME YourAssembly.YourClass.YourMethod;
  • Ensure clr enabled and clr strict security server configuration options are correctly set via:
  EXEC sp_configure 'clr enabled', 1;
  RECONFIGURE;

Step 4: Validate Server and Assembly Trust Settings

  • On Windows Server 2025 / Windows 11, confirm the assembly DLL is signed and added to the trusted assemblies list if clr strict security is enabled:
  EXEC sp_add_trusted_assembly @hash = 0x<AssemblyHash>, @description = N'YourAssembly';
  • Restart the SQL Server service (services.msc → SQL Server (MSSQLSERVER) → Restart) to ensure the metadata cache is refreshed after redeployment.

Alternative or Verification Steps

  • Verify the fix by re-running the original deployment/migration script end-to-end; it should complete without raising Error 1096, and sys.parameters should show has_default_value = 0 for all CLR-typed parameters.
  • If the error persists, as a workaround, convert the parameter to a nullable scalar type (e.g., NVARCHAR(MAX)) at the T-SQL boundary and perform the CLR type conversion inside the method body instead of at the procedure signature level.

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

Why This Error Happens

This error occurs when a Data Definition Language (DDL) statement—typically CREATE TRIGGER, CREATE EVENT NOTIFICATION, or CREATE EVENT SESSION—contains a duplicate event type in the same FOR or ON clause. SQL Server’s parser validates that each event type (e.g., INSERT, UPDATE, DELETE, or a specific extended event) appears only once per statement, and it throws Error 1095 when it detects a repeated entry. This is almost always a scripting or copy-paste mistake rather than a server configuration, permissions, or corruption issue.

Step-by-Step Resolution Guide

Step 1: Locate the Offending Script

  • Identify the exact T-SQL batch that triggered Error 1095 by checking the SQL Server Error Log (Management > SQL Server Logs in SSMS) or the session that executed the DDL statement.
  • Note the full object name reported in the error message (e.g., trigger name, event session name) since it pinpoints which CREATE/ALTER statement is failing.

Step 2: Inspect the FOR/ON Clause for Duplicate Event Types

  • Open the script in SQL Server Management Studio (SSMS) and locate the FOR clause (for triggers) or ADD EVENT clause (for Extended Events sessions).
  • Example of a faulty trigger definition:
  CREATE TRIGGER trg_Example
  ON dbo.Orders
  FOR INSERT, UPDATE, INSERT
  AS BEGIN ... END
  • Remove the duplicate keyword so each event type (INSERT, UPDATE, DELETE) is listed only once.

Step 3: Validate Extended Events Session Definitions

  • If the error originates from CREATE EVENT SESSION, open the session script and check the ADD EVENT block for repeated event names.
  • Use this query to review existing sessions and their event definitions before redeploying:
  SELECT s.name AS session_name, e.name AS event_name
  FROM sys.server_event_sessions AS s
  JOIN sys.server_event_session_events AS e
      ON s.event_session_id = e.event_session_id;
  • Edit the script to eliminate any duplicate ADD EVENT entries for the same event name.

Step 4: Re-run the Corrected Script

  • Save the corrected script and execute it in a test environment first (non-production instance on Windows Server 2025 or local Windows 11 developer instance) using SSMS or sqlcmd.
  • Confirm the object (trigger, event notification, or event session) is created successfully without raising Error 1095.

Step 5: Deploy to Production

  • Once validated, deploy the corrected script to the production SQL Server 2025 instance during a maintenance window.
  • Document the change in your deployment/version control system to prevent reintroducing the duplicate event type in future script updates.

Alternative or Verification Steps

  • Verify the fix by querying sys.triggers and sys.trigger_events (for triggers) or sys.server_event_sessions (for Extended Events) to confirm only one row exists per event type for the affected object.
  • If the error persists despite a visually correct script, check for hidden whitespace/encoding issues or multiple nested scripts (e.g., included via sqlcmd :r or deployment tools) that may be concatenating duplicate FOR/ADD EVENT clauses before execution.

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

Troubleshooting Guide: Error 1094 – Cannot Specify Schema Name Prefix for Database/Server-Level Triggers

Why This Error Happens

Error 1094 occurs because DDL triggers at the database (ON DATABASE) or server (ON ALL SERVER) scope do not belong to a schema, unlike regular DML triggers that are schema-bound to a table or view. SQL Server 2025 enforces strict T-SQL syntax validation, and prefixing the trigger name with a schema (e.g., dbo.TriggerName) is only valid for DML triggers created on a specific table or view. This is typically caused by a scripting error, a migrated/legacy script from an older DML trigger template, or a misunderstanding of trigger scope during trigger creation.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Script

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and locate the failing CREATE TRIGGER or ALTER TRIGGER statement.
  • Check the trigger creation statement for a pattern like:
  CREATE TRIGGER dbo.TriggerName ON DATABASE
  • Confirm whether the trigger is intended to be a database-level or server-level trigger by checking for ON DATABASE or ON ALL SERVER clauses.

Step 2: Remove the Schema Prefix from the Trigger Name

  • Edit the script to strip the schema name (e.g., dbo.) from the trigger identifier.
  • Correct syntax for a database-level trigger:
  CREATE TRIGGER TriggerName
  ON DATABASE
  FOR CREATE_TABLE
  AS
  BEGIN
      PRINT 'Table Created';
  END;
  • Correct syntax for a server-level trigger:
  CREATE TRIGGER TriggerName
  ON ALL SERVER
  FOR CREATE_DATABASE
  AS
  BEGIN
      PRINT 'Database Created';
  END;
  • Save the corrected script to C:\Scripts\SQL\FixedTriggers.sql or your preferred repository path for version tracking.

Step 3: Re-Execute the Script in the Correct Context

  • For database-level triggers, ensure you are connected to the correct target database in SSMS (check the database dropdown in the toolbar).
  • For server-level triggers, ensure you are connected to the server instance root context, not a specific user database.
  • Re-run the corrected CREATE TRIGGER statement using F5 or the Execute button in SSMS.

Step 4: Validate Trigger Registration

  • Query sys.triggers (for database-level) or sys.server_triggers (for server-level) to confirm the trigger was created without errors:
  SELECT name, parent_class_desc FROM sys.triggers WHERE parent_class = 0;
  SELECT name FROM sys.server_triggers;
  • Confirm there are no duplicate or orphaned trigger entries from failed prior attempts.

Alternative or Verification Steps

  • Run SELECT * FROM sys.triggers WHERE name = 'TriggerName'; to verify the trigger exists without a schema association, confirming the fix was applied correctly.
  • If the error persists, check for cached or pooled connections in SSMS by opening a new query window (Ctrl+N) to rule out stale session metadata causing false-positive syntax errors.

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

Why This Error Happens

Error 1093 occurs when SQL Server Service Broker encounters a broker instance identifier (GUID) that is malformed, truncated, or does not conform to the expected GUID format in the sys.databases or sys.service_broker_endpoints system catalogs. This typically results from manual edits to the broker GUID via ALTER DATABASE SET NEW_BROKER or SET ENABLE_BROKER commands gone wrong, database restoration from a corrupted backup, or a mismatch introduced during a database copy/attach operation where the broker identifier wasn’t properly regenerated. In some cases, this also surfaces after an in-place upgrade to SQL Server 2025 when legacy broker metadata from an older compatibility level is not reconciled correctly.

Step-by-Step Resolution Guide

Step 1: Verify the Current Broker GUID Status

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio connected to the affected instance.
  • Run the following query to inspect the broker configuration:
  SELECT name, database_id, is_broker_enabled, service_broker_guid 
  FROM sys.databases 
  WHERE name = 'YourDatabaseName';
  • Confirm whether service_broker_guid is NULL, malformed, or duplicated across databases.

Step 2: Reset the Service Broker GUID

  • If the GUID is invalid or duplicated, generate a new one using:
  ALTER DATABASE [YourDatabaseName] SET NEW_BROKER WITH ROLLBACK IMMEDIATE;
  • If you need to preserve existing conversations/messages (not advised in most recovery scenarios), instead use:
  ALTER DATABASE [YourDatabaseName] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
  • Ensure no active connections are using the database when running this command, as it requires exclusive access.

Step 3: Check and Repair Broker Endpoint Configuration

  • Navigate to SQL Server Configuration Manager and confirm the Service Broker endpoint port (commonly 4022) is not conflicting with another process on Windows Server 2025.
  • Run netstat -ano | findstr 4022 in an elevated PowerShell/Command Prompt to confirm no port collision exists.
  • Re-create the broker endpoint if needed:
  CREATE ENDPOINT [Broker_Endpoint]
  STATE = STARTED
  AS TCP (LISTENER_PORT = 4022)
  FOR SERVICE_BROKER (AUTHENTICATION = WINDOWS);

Step 4: Restart SQL Server Service and Validate System Catalogs

  • Restart the SQL Server service via services.msc or run:
  Restart-Service -Name "MSSQLSERVER" -Force
  • After restart, re-query sys.databases to confirm service_broker_guid now shows a valid, properly formatted GUID (e.g., A1B2C3D4-E5F6-7890-ABCD-EF1234567890).

Alternative or Verification Steps

  • Verify the fix by sending a test message through a Service Broker queue (SEND ON CONVERSATION) and confirming it processes without raising Error 1093 in the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • If the error persists, consider restoring the database from a known-good backup with a validated broker configuration, then reapply ALTER DATABASE SET NEW_BROKER to assign a fresh, uncorrupted GUID.

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

Troubleshooting Guide: SQL Server Error 1091 – “The option “%ls” is not valid for this function”

Why This Error Happens

This error occurs when a T-SQL statement references a function option, parameter, or property flag that is either misspelled, deprecated, or unsupported by the SQL Server 2025 database engine. It commonly surfaces when scripts written for older configurations (such as legacy DBCC, sp_configure, or metadata functions) pass an argument that the function no longer recognizes due to engine changes in SQL Server 2025. Corrupted or outdated compatibility-level settings on the database can also trigger this mismatch between the expected option set and the one actually being parsed.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Statement

  • Check the SQL Server Error Log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the exact query or batch that triggered Error 1091.
  • Use SQL Server Profiler or Extended Events (xEvents) to capture the precise statement and the invalid option string.
  • Run SELECT * FROM sys.dm_exec_requests WHERE session_id = <id> to correlate the failing session.

Step 2: Validate Function Syntax Against SQL Server 2025 Documentation

  • Compare the flagged option against the current Microsoft Docs reference for that specific function (e.g., DBCC, OPENROWSET, sp_configure).
  • Look specifically for deprecated keywords — SQL Server 2025 removed or renamed several legacy options compared to SQL Server 2019/2022.
  • Update the script to use the current supported parameter name or equivalent replacement function.

Step 3: Check Database Compatibility Level

  • Open SQL Server Management Studio (SSMS) and run:
  SELECT name, compatibility_level FROM sys.databases;
  • If the compatibility level is outdated (below 160), update it to match SQL Server 2025 standards:
  ALTER DATABASE [YourDBName] SET COMPATIBILITY_LEVEL = 170;
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell (Run as Administrator) to apply changes cleanly.

Step 4: Rebuild or Refresh Affected Stored Procedures

  • If the error originates from a stored procedure using a deprecated option, drop and recreate it with corrected syntax.
  • Run sp_refreshsqlmodule 'SchemaName.ProcedureName' to ensure cached metadata is updated.
  • Clear the procedure cache if needed: DBCC FREEPROCCACHE;

Alternative or Verification Steps

  • Re-run the original query or job that failed; confirm no Error 1091 appears in the Error Log or SSMS Messages pane.
  • If the issue persists, restore the affected database from a pre-upgrade backup and re-apply only verified, compatible scripts to isolate the exact breaking change.

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

Troubleshooting Guide: SQL Server Error 1092

Why This Error Happens

This error occurs when a T-SQL statement—most commonly UPDATE STATISTICS or an index/statistics maintenance command—is passed more statistics names than the specified option supports. Certain options (such as those expecting a single column or a single statistics object) are hard-coded to accept only one identifier, and supplying multiple comma-separated names violates that syntax constraint. This is typically a query authoring issue rather than a server configuration problem, but it can also surface from outdated maintenance scripts, third-party tools, or ORM-generated statements that were not updated for SQL Server 2025 syntax changes.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Statement

  • Check the SQL Server error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the exact query batch tied to Error 1092.
  • Use SQL Server Profiler or Extended Events (sqlserver.error_reported) to capture the precise statement and session that triggered the error.
  • Note the %ls option name reported in the error text—this tells you which clause is misconfigured.

Step 2: Correct the Statistics Name List in the Query

  • Open the script in SQL Server Management Studio (SSMS) and locate the UPDATE STATISTICS, CREATE STATISTICS, or DROP STATISTICS command.
  • Ensure options like WITH FULLSCAN, WITH RESAMPLE, or WITH SAMPLE are not being passed multiple statistics names if the option restricts input to one.
  • Split the command into separate statements, one per statistics name, for example:
  UPDATE STATISTICS dbo.SalesOrder (IX_Stat1);
  UPDATE STATISTICS dbo.SalesOrder (IX_Stat2);
  • Avoid comma-separating names where the specific option clause only accepts a single value.

Step 3: Audit and Update Maintenance Scripts/Jobs

  • Review SQL Server Agent jobs under SQL Server Agent > Jobs in SSMS for legacy statistics maintenance scripts (e.g., Ola Hallengren’s IndexOptimize or custom scripts).
  • Update any script referencing deprecated multi-name syntax to match SQL Server 2025’s stricter parsing rules.
  • Redeploy the corrected script and re-run the job manually to confirm the error no longer appears in the job history.

Step 4: Validate Application/ORM-Generated Queries

  • If the error originates from an application (e.g., Entity Framework, a reporting tool), check the generated SQL via SQL Server Profiler.
  • Update the application’s data access layer or stored procedure to generate one statistics name per statement.
  • Redeploy the updated application build to Windows Server 2025/Windows 11 client machines.

Alternative or Verification Steps

  • Re-run the corrected statement directly in SSMS against a test database and confirm it completes without Error 1092 in the Messages tab.
  • Check sys.stats and sys.dm_db_stats_properties to confirm the statistics object was updated/created successfully as expected.

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

Troubleshooting Guide: SQL Server Error 1090 – “Invalid Default for Parameter %d”

Why This Error Happens

This error occurs when a stored procedure, function, or parameterized query receives a default value that does not match the expected data type, scope, or constraint of the declared parameter. It commonly arises from schema drift after an in-place upgrade to SQL Server 2025, where legacy T-SQL default bindings or deprecated datatype aliases are no longer implicitly convertible. Corrupted procedure cache entries or an improperly deployed DACPAC/migration script can also leave a parameter definition out of sync with its metadata in sys.parameters.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Object and Parameter

  • Capture the full error text from the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) to get the parameter ordinal number (%d).
  • Run the following query to cross-reference the parameter with its parent object:
  SELECT p.name, p.parameter_id, p.default_value, o.name AS object_name
  FROM sys.parameters p
  JOIN sys.objects o ON p.object_id = o.object_id
  WHERE p.parameter_id = <ordinal_from_error>;
  • Note the object_name and current default_value for comparison against source control.

Step 2: Correct the Parameter Definition in T-SQL

  • Open the procedure/function definition using SQL Server Management Studio (SSMS) 21 or Azure Data Studio.
  • Ensure the default value matches the declared datatype exactly (e.g., do not pass NULL as a default for a parameter declared NOT NULL, or a string literal for an INT type).
  • Re-deploy using ALTER PROCEDURE with the corrected syntax:
  ALTER PROCEDURE dbo.YourProcName
      @ParamName INT = 0  -- ensure type matches
  AS
  BEGIN
      ...
  END

Step 3: Clear Corrupted Plan Cache and Metadata

  • If the definition looks correct but the error persists, the cached execution plan may hold stale metadata.
  • Run DBCC FREEPROCCACHE; to clear the global plan cache (use with caution on production during low-traffic windows).
  • Alternatively, target the specific plan using DBCC FREEPROCCACHE (plan_handle) retrieved from sys.dm_exec_cached_plans.

Step 4: Validate Compatibility Level Settings

  • Since this is SQL Server 2025 on Windows Server 2025, confirm the database compatibility level supports the newer parameter-sniffing and default-binding behavior.
  • Check and set compatibility level via:
  SELECT compatibility_level FROM sys.databases WHERE name = 'YourDB';
  ALTER DATABASE YourDB SET COMPATIBILITY_LEVEL = 170;
  • Restart the SQL Server service via services.msc or Restart-Service MSSQLSERVER in PowerShell (Run as Administrator) to apply changes cleanly.

Alternative or Verification Steps

  • Execute the stored procedure manually with explicit parameter values (bypassing the default) to confirm the underlying logic works, then re-test using the default value to isolate the issue.
  • If the error persists after redeployment, restore the object definition from a known-good backup or source-controlled script using sqlpackage.exe to rule out DACPAC deployment corruption.

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

Troubleshooting Guide: SQL Server Error 1089 — “SET FMTONLY OFF statement must be the last statement in the batch”

Why This Error Happens

This error occurs because SET FMTONLY OFF is a legacy T-SQL command that SQL Server 2025 requires to be isolated as the only statement in its batch — it cannot be combined with other queries, variable declarations, or control-of-flow logic. This typically happens when ORM frameworks (like older versions of Entity Framework or Hibernate), legacy drivers, or auto-generated scripts append SET FMTONLY OFF; directly before a stored procedure call or dynamic SQL block in the same batch. Since SQL Server 2025 has tightened parser validation around deprecated metadata-only execution modes, batches that previously executed with a warning now fail outright with Error 1089.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Batch

  • Capture the exact query text using SQL Server Profiler or Extended Events (sp_server_diagnostics or a trace filtered on Error 1089).
  • Check application logs, connection strings, or middleware (e.g., .NET Data Providers, JDBC drivers) for any auto-injected SET FMTONLY OFF statements.
  • Open the script in SSMS and locate where SET FMTONLY OFF is concatenated with other T-SQL statements using a semicolon or newline without a GO separator.

Step 2: Isolate the SET FMTONLY OFF Statement

  • Edit the batch so that SET FMTONLY OFF; appears as its own standalone batch, separated by a GO statement from the subsequent query.
  • Example fix:
  SET FMTONLY OFF;
  GO
  EXEC dbo.YourStoredProcedure;
  • If the statement is being generated dynamically by an application layer, update the connection or command builder logic to send it as a separate ExecuteNonQuery() call rather than appending it to the main command string.

Step 3: Update Legacy Drivers or ORM Configuration

  • Navigate to your application’s data access layer configuration (e.g., web.config, appsettings.json, or driver connection properties).
  • Disable any legacy “schema-only” or “FMTONLY” metadata detection flags — most modern drivers (ODBC 18+, OLE DB 19+) use sp_describe_first_result_set instead and no longer require SET FMTONLY.
  • Update the driver via Windows Server 2025 Feature Management or reinstall the latest Microsoft ODBC Driver from the official Microsoft Download Center.

Step 4: Remove Deprecated FMTONLY Calls Entirely

  • Since SET FMTONLY has been deprecated since SQL Server 2012 and is fully unsupported in metadata discovery as of SQL Server 2025, consider removing it altogether.
  • Replace its functionality with sys.sp_describe_first_result_set or SET NOEXEC ON where applicable for result-set-only validation.

Alternative or Verification Steps

  • Re-run the original failing query/application transaction in SQL Server Management Studio (SSMS) to confirm Error 1089 no longer appears in the Messages pane.
  • If the error persists, check SQL Server Error Logs (Event Viewer > Applications and Services Logs > MSSQLSERVER) for Event ID 1089 recurrence, and confirm no third-party middleware (e.g., ETL tools, legacy BI connectors) is re-injecting the deprecated syntax during connection pooling.

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

Troubleshooting Guide: SQL Server Error 1088

Why This Error Happens

Error 1088 occurs when SQL Server cannot locate the specified object (table, view, stored procedure, or index) in the current database context, typically because the object was dropped, renamed, or never existed under that name. This can also occur when the object exists but resides in a different schema than the one being referenced, causing a name resolution mismatch. Additionally, insufficient permissions on the object can trigger this same error message as a security obfuscation measure, preventing unauthorized users from confirming whether an object exists at all.

Step-by-Step Resolution Guide

Step 1: Verify the Object Exists in the Target Database

  • Open SQL Server Management Studio (SSMS) and connect to the correct instance.
  • Run the following query to search across all schemas:
  SELECT * FROM sys.objects WHERE name LIKE '%YourObjectName%';
  • Confirm you are connected to the intended database using SELECT DB_NAME();, as the object may exist in a different database context.

Step 2: Check and Correct Schema References

  • Explicitly qualify the object with its schema name in your query (e.g., dbo.TableName instead of just TableName).
  • Run the following to identify the correct schema:
  SELECT s.name AS SchemaName, o.name AS ObjectName
  FROM sys.objects o
  JOIN sys.schemas s ON o.schema_id = s.schema_id
  WHERE o.name = 'YourObjectName';
  • Update any stored procedures, views, or application connection strings referencing the incorrect schema.

Step 3: Validate User Permissions on the Object

  • Check effective permissions using:
  SELECT * FROM fn_my_permissions('dbo.YourObjectName', 'OBJECT');
  • If permissions are missing, grant access via:
  GRANT SELECT, INSERT, UPDATE ON dbo.YourObjectName TO [YourUserOrRole];
  • Ensure the login is mapped to the correct database user under Security > Logins > [Login Name] > User Mapping in SSMS.

Step 4: Rebuild or Restore the Object if Missing

  • If the object was accidentally dropped, restore it from a recent backup using RESTORE DATABASE with a point-in-time recovery if needed.
  • Alternatively, re-run the original DDL script (CREATE TABLE, CREATE VIEW, etc.) from source control or a deployment pipeline.
  • On Windows Server 2025, check the SQL Server error logs located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for any DROP or ALTER statements that may have removed the object unexpectedly.

Alternative or Verification Steps

  • Re-run the original failing query or application call and confirm Error 1088 no longer appears in SSMS or the Windows Event Viewer under Applications and Services Logs > MSSQLSERVER.
  • If the issue persists, use SQL Server Profiler or Extended Events to trace the exact object name and login being used at the time of failure, as mismatched case-sensitivity (if the instance uses a case-sensitive collation) can also cause this error.

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

Troubleshooting Guide: Error 1087 – “Must declare the table variable”

Why This Error Happens

This error occurs when a Transact-SQL batch or stored procedure references a table variable (prefixed with @) that is either out of scope, misspelled, or was never declared with a DECLARE @TableVar TABLE (...) statement in the current batch. Because table variables have strict scoping rules in SQL Server 2025, they cannot be referenced across separate GO batch boundaries, inside dynamic SQL without explicit passing, or in a nested scope where the declaration isn’t visible. This is almost always a code-logic or batch-separation issue rather than a server configuration or permissions problem.

Step-by-Step Resolution Guide

Step 1: Inspect the Batch Boundaries in Your Script

  • Open the script in SQL Server Management Studio (SSMS) and check for any GO statements between the DECLARE @TableVar TABLE (...) line and the line where it’s referenced.
  • Remember that GO ends the current batch, destroying all local variables, including table variables.
  • Remove unnecessary GO separators so the declaration and usage remain in the same batch.

Step 2: Verify Spelling and Case Sensitivity

  • Compare the variable name used in DECLARE @MyTable TABLE (...) against every subsequent reference (e.g., SELECT * FROM @MyTbl) for typos.
  • Check if the database collation is case-sensitive (e.g., SQL_Latin1_General_CP1_CS_AS); if so, @MyTable and @mytable are treated as different identifiers.
  • Run sp_helpdb or check DATABASEPROPERTYEX('YourDB', 'Collation') in a query window to confirm collation settings.

Step 3: Check Scope in Stored Procedures and Dynamic SQL

  • Confirm the table variable is not being referenced inside an EXEC() or sp_executesql call, as dynamic SQL runs in its own scope and cannot see the outer variable.
  • If dynamic SQL needs the data, pass it via a Table-Valued Parameter (TVP) instead:
  • Define a user-defined table type using CREATE TYPE MyTableType AS TABLE (...).
  • Pass the table variable as a parameter to sp_executesql using this type.

Step 4: Validate Nested Procedure or Trigger Logic

  • If the error originates inside a nested stored procedure or trigger, confirm the table variable wasn’t declared in the calling procedure and assumed to be “global.”
  • Table variables are strictly local; redeclare the table structure inside the nested object or pass data explicitly via a TVP.

Alternative or Verification Steps

  • To verify the fix, execute the corrected batch in SSMS or Azure Data Studio and confirm the query returns results or completes without raising Error 1087.
  • As an alternative, if the table variable’s scope is overly complex, consider replacing it with a temporary table (#TempTable), which persists across batches within the same session and can simplify scope management.

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

Troubleshooting Guide: Error 1086 — “The FOR XML and FOR JSON Clauses Are Invalid in Views”

Why This Error Happens

This error occurs because SQL Server 2025 enforces a T-SQL syntax restriction that prohibits the use of FOR XML or FOR JSON clauses directly within a CREATE VIEW or ALTER VIEW statement. This is not a permissions or configuration issue — it is a language parser restriction baked into the SQL Server Database Engine. The error typically surfaces when a developer migrates a stored procedure’s logic into a view, or when ORM-generated SQL attempts to wrap XML/JSON serialization inside a view definition.

Step-by-Step Resolution Guide

Step 1: Identify the Offending View Definition

  • Open SQL Server Management Studio (SSMS) 21 or Azure Data Studio connected to your SQL Server 2025 instance.
  • Run the following query to locate the view causing the issue:
  SELECT name, definition 
  FROM sys.sql_modules m
  JOIN sys.views v ON m.object_id = v.object_id
  WHERE definition LIKE '%FOR XML%' OR definition LIKE '%FOR JSON%';
  • Confirm the FOR XML/FOR JSON clause sits at the outermost level of the SELECT statement inside the view body.

Step 2: Refactor the Logic Using a Wrapper Query or Table-Valued Function

  • Remove the FOR XML/FOR JSON clause from the view definition itself.
  • Convert the view into a standard relational view (without the XML/JSON clause):
  ALTER VIEW dbo.vw_CustomerData AS
  SELECT CustomerID, Name, Email FROM dbo.Customers;
  • Move the FOR XML/FOR JSON serialization to the calling query instead:
  SELECT * FROM dbo.vw_CustomerData FOR JSON AUTO;
  • If the business logic requires the serialization to be reusable, convert the view into an Inline Table-Valued Function (iTVF) instead, since iTVFs support parameters but still require the clause to be applied at the consuming query level.

Step 3: Update Dependent Application Code and ORM Mappings

  • Check Entity Framework, Dapper, or SSIS packages that reference the view, as they may expect pre-serialized XML/JSON output.
  • Update connection strings or data access layers (e.g., .NET 9 repositories) to append FOR JSON PATH or FOR XML PATH at the application query level rather than relying on the view to do it.
  • Redeploy the updated schema using your CI/CD pipeline (e.g., Azure DevOps or GitHub Actions with SqlPackage.exe) to ensure the corrected view script overwrites the broken one in Production.

Alternative or Verification Steps

  • Verify the fix by executing sp_helptext 'dbo.vw_CustomerData' in SSMS to confirm the view no longer contains the restricted clause, then run a test SELECT ... FOR JSON AUTO against the view to ensure data serializes correctly.
  • If refactoring the view is not immediately feasible, create a Stored Procedure instead of a View, as Stored Procedures in SQL Server 2025 fully support FOR XML and FOR JSON clauses natively without restriction.

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

Troubleshooting Guide: SQL Server Error 1085 – Event Notification Not Supported

Why This Error Happens

This error occurs when a Data Definition Language (DDL) statement or trace attempts to bind an event notification to an event type that does not support asynchronous notification delivery in SQL Server 2025. Typically, this happens when the event group specified in the CREATE EVENT NOTIFICATION statement includes a reserved system event (such as certain DDLSERVERLEVEL_EVENTS subtypes) that is explicitly excluded from the Service Broker notification architecture. It can also be triggered by corrupted system metadata in the sys.event_notifications catalog view following an in-place upgrade from SQL Server 2019/2022 to 2025.

Step-by-Step Resolution Guide

Step 1: Identify the Unsupported Event Type

  • Query the error log to capture the exact event name reported in the %.*ls placeholder.
  • Run the following T-SQL to cross-reference the event against supported types:
  SELECT * FROM sys.event_notification_event_types 
  WHERE type_name = 'YOUR_EVENT_NAME_HERE';
  • Confirm if the event belongs to a restricted category (e.g., TRACE_CHANGE_GROUP in newer builds).

Step 2: Modify the Event Notification Script

  • Remove the unsupported event type from the FOR clause in your CREATE EVENT NOTIFICATION syntax.
  • Replace broad group calls (like FOR DDL_SERVER_LEVEL_EVENTS) with specific, supported granular events to avoid future conflicts.
  • Re-deploy the notification using SQL Server Management Studio (SSMS) 21 or Azure Data Studio.

Step 3: Clear Corrupted Metadata Cache

  • Open a Command Prompt as Administrator on your Windows Server 2025 host.
  • Restart the SQL Server service to clear the plan cache and metadata locks:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • If the issue persists, run DBCC FREESYSTEMCACHE('ALL') to force a refresh of the internal event-type cache.

Step 4: Check for Compatibility Level Mismatches

  • Navigate to Database Properties > Options in SSMS.
  • Ensure the Database Compatibility Level is set to 170 (SQL Server 2025) to ensure the event notification engine aligns with the installed engine binaries.
  • Update the level using: ALTER DATABASE YourDB SET COMPATIBILITY_LEVEL = 170;

Alternative or Verification Steps

  • Verification: Check the SQL Server Error Log (via EXEC sp_readerrorlog) to confirm Error 1085 no longer appears after the service restart and script redeployment.
  • Alternative: If the specific event type is fundamentally unsupported by the Service Broker architecture, pivot to using Extended Events (XEvents) instead, as they offer broader event coverage for monitoring without the architectural overhead of Service Broker queues.

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

Troubleshooting Guide: SQL Server Error 1084 – “%.*ls’ is an invalid event type”

Why This Error Happens

This error occurs when SQL Server 2025’s Event Notification or Extended Events engine receives a malformed or unrecognized event type string, typically caused by a mismatch between the event name defined in a CREATE EVENT NOTIFICATION or CREATE EVENT SESSION statement and the event catalog stored in system metadata. This commonly arises after an in-place upgrade from an older SQL Server version where deprecated event types persist in DDL scripts, or when a corrupted sys.event_notification_event_types system view/catalog cache prevents proper event resolution. It can also surface when third-party monitoring tools or SSMS templates reference event names that were renamed or removed in SQL Server 2025.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Event Type String

  • Enable SQL Server error logging detail by running DBCC TRACEON(3604, -1) in a query window to capture the exact event name causing the failure.
  • Check the SQL Server Error Log (Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the full text of Error 1084 surrounding the timestamp of failure.
  • Cross-reference the flagged event name against SELECT * FROM sys.event_notification_event_types ORDER BY type_name; to confirm whether it exists in the current catalog.

Step 2: Correct or Remove the Invalid Event Definition

  • Open the script or application (SSMS, SSIS package, or custom T-SQL) that issued the CREATE EVENT NOTIFICATION or CREATE EVENT SESSION command.
  • Replace deprecated event names (e.g., old DDL_ or TRACE_ prefixed events no longer supported) with their SQL Server 2025 equivalents listed in sys.event_notification_event_types.
  • Run the corrected script:
  DROP EVENT NOTIFICATION IF EXISTS [YourNotificationName] ON SERVER;
  CREATE EVENT NOTIFICATION [YourNotificationName]
  ON SERVER
  FOR DDL_DATABASE_LEVEL_EVENTS
  TO SERVICE 'YourServiceName', 'current database';

Step 3: Rebuild System Catalog Views if Corruption Is Suspected

  • Run DBCC CHECKDB('master') WITH NO_INFOMSGS, ALL_ERRORMSGS; to rule out metadata corruption in the master database.
  • If corruption is found, restore master from a known-good backup or rebuild system databases using setup.exe /ACTION=REBUILDDATABASE from the SQL Server 2025 installation media.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER after rebuilding.

Step 4: Patch and Update SQL Server Components

  • Confirm you are running the latest Cumulative Update (CU) for SQL Server 2025 via SELECT @@VERSION;.
  • Download and apply the newest CU from the Microsoft Update Catalog if the build number is outdated, as early 2025 builds had known event-type registration bugs.
  • Reboot Windows Server 2025 / Windows 11 after patching to ensure the Extended Events engine reinitializes cleanly.

Alternative or Verification Steps

  • Verify the fix by re-running the original CREATE EVENT NOTIFICATION/CREATE EVENT SESSION statement and confirming it completes without Error 1084, then check sys.server_event_notifications or sys.server_event_sessions to confirm the object was created successfully.
  • If the issue persists, use Extended Events in SSMS (Management > Extended Events > New Session Wizard) to recreate the session graphically, which validates event names automatically and avoids manual typos in T-SQL scripts.

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

Troubleshooting Guide: Error 1083 — “OWNER is not a valid option for EXECUTE AS” in SQL Server Triggers

Why This Error Happens

This error occurs because SQL Server 2025 restricts the EXECUTE AS OWNER clause when defining server-level or database-level DDL triggers, as the OWNER principal context is not supported at this scope. Unlike DML triggers on tables, server and database triggers only accept EXECUTE AS values such as CALLER, SELF, or a specific valid 'user_name'. This is typically caused by scripts migrated from older trigger templates or third-party tools that incorrectly assume OWNER is universally valid across all trigger types.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Trigger Definition

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and connect to the affected instance.
  • Run the following query to locate server/database-level triggers using EXECUTE AS:
  SELECT name, OBJECT_DEFINITION(object_id) AS definition
  FROM sys.server_triggers;
  • Also check sys.triggers for database-scoped DDL triggers with similar syntax.

Step 2: Modify the EXECUTE AS Clause

  • Replace EXECUTE AS OWNER with a supported context such as EXECUTE AS SELF or EXECUTE AS 'DOMAIN\ServiceAccount'.
  • Example corrected syntax:
  CREATE TRIGGER trg_AuditServerChanges
  ON ALL SERVER
  WITH EXECUTE AS SELF
  FOR CREATE_DATABASE
  AS
  BEGIN
      PRINT 'Database created';
  END;
  • If the original intent was to run as the database owner, explicitly specify that login name instead of using the OWNER keyword.

Step 3: Drop and Recreate the Trigger

  • Use DROP TRIGGER followed by the corrected CREATE TRIGGER statement on the affected server or database scope.
  • Ensure the executing login has CONTROL SERVER (for server-level triggers) or ALTER ANY DATABASE DDL TRIGGER (for database-level triggers) permissions before recreation.

Step 4: Validate Permissions on the Impersonated Account

  • If using EXECUTE AS 'user_name', confirm that account exists and has IMPERSONATE permission granted:
  GRANT IMPERSONATE ON LOGIN::[DOMAIN\ServiceAccount] TO [YourExecutingLogin];
  • On Windows Server 2025/Windows 11, verify the Windows account isn’t disabled or locked via Computer Management > Local Users and Groups.

Alternative or Verification Steps

  • Re-run the CREATE TRIGGER script in a test database; if it compiles without Error 1083, the fix is confirmed.
  • As an alternative, if ownership-based execution is strictly required, create a dedicated proxy login matching the intended owner’s permissions and reference it explicitly in EXECUTE AS 'login_name' instead of relying on the unsupported OWNER keyword.

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

Why This Error Happens

Error 1082 occurs when an application or extension attempts to register a trigger using a synchronous notification method on a database object (such as a Service Broker queue or Query Notification) that only supports asynchronous event delivery. This typically happens due to a mismatch between the SQL Server Native Client driver version and the server-side notification subsystem, or because the target object was created with an incompatible WITH CHANGE_TRACKING or NOTIFICATION configuration. It can also surface after an in-place upgrade to SQL Server 2025 where legacy connection strings still request deprecated synchronous callback behavior.

Step-by-Step Resolution Guide

Step 1: Verify the Connection String and Driver Version

  • Open the application’s configuration file or connection pooling settings and locate the Provider or Driver attribute.
  • Ensure the client is using ODBC Driver 18 for SQL Server or later, as older drivers (SQL Native Client, ODBC 11/13) do not fully support SQL Server 2025’s asynchronous-only trigger model.
  • Run sqlcmd -S <ServerName> -Q "SELECT @@VERSION" from an elevated PowerShell window to confirm the server build matches SQL Server 2025 (16.x).

Step 2: Audit the Trigger or Notification Registration Code

  • Search the application source (or SSMS query history) for calls using SqlDependency, SqlNotificationRequest, or custom CLR triggers that explicitly set a synchronous registration flag.
  • Open SQL Server Management Studio (SSMS 21) and run:
  SELECT name, type_desc, is_disabled FROM sys.triggers WHERE OBJECTPROPERTY(object_id, 'ExecIsTriggerDisabled') = 0;
  • Modify any code registering triggers with NotificationType.Synchronous to use NotificationType.Asynchronous instead, as required by the new engine.

Step 3: Reconfigure Service Broker and Query Notification Settings

  • Navigate to Control Panel > Administrative Tools > Services and confirm the SQL Server Service Broker is running under the correct service account.
  • In SSMS, verify Broker is enabled on the database:
  ALTER DATABASE [YourDB] SET ENABLE_BROKER;
  • Check C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for any corresponding Broker initialization failures that might be forcing a synchronous fallback.

Step 4: Apply the Latest Cumulative Update

  • Go to C:\Windows\Temp\SQLSetup (or your deployment share) and download the latest Cumulative Update (CU) for SQL Server 2025 from the Microsoft Update Catalog.
  • Run the installer as Administrator and select Repair if the existing instance shows corrupted binaries related to sqlncli.dll or msoledbsql.dll.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc after the update completes.

Alternative or Verification Steps

  • After applying the fixes, re-run the application’s trigger registration routine and monitor the SQL Server Error Log (Event Viewer > Applications and Services Logs > MSSQLSERVER) to confirm Error 1082 no longer appears.
  • As a workaround, if the application cannot be modified immediately, disable Query Notifications at the application layer and switch to a polling-based mechanism until the client library is updated to a fully asynchronous-compatible version.

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

Troubleshooting Guide: SQL Server Error 1081 — Invalid Database Name Prefix in Assembly Reference

Why This Error Happens

This error occurs when a T-SQL statement, typically CREATE ASSEMBLY, ALTER ASSEMBLY, or a reference to a CLR assembly, incorrectly includes a database name as a prefix to the assembly name (e.g., MyDatabase.MyAssembly instead of just MyAssembly). SQL Server 2025 enforces strict scoping rules for assemblies, meaning assembly names must be resolved within the context of the currently connected database rather than through three-part or cross-database naming conventions. This commonly happens when scripts are copied from older documentation, migrated from legacy systems, or generated by tools that assume cross-database assembly syntax is supported.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Statement

  • Locate the script or stored procedure that is throwing Error 1081 in SQL Server Management Studio (SSMS) or Azure Data Studio.
  • Check the CREATE ASSEMBLY, ALTER ASSEMBLY, or DROP ASSEMBLY statements for a database-qualified name such as AdventureWorks.dbo.MyAssembly.
  • Run the following to isolate the exact query batch causing the failure:
  SELECT * FROM sys.assemblies WHERE name LIKE '%YourAssemblyName%';

Step 2: Correct the Assembly Reference Syntax

  • Remove the database name prefix from the assembly reference. The correct syntax only requires the assembly name itself, since CREATE ASSEMBLY always operates within the context of the current database.
  • Change a statement like this:
  CREATE ASSEMBLY AdventureWorks.MyAssembly FROM 'C:\Assemblies\MyAssembly.dll';

To this:

  USE AdventureWorks;
  GO
  CREATE ASSEMBLY MyAssembly FROM 'C:\Assemblies\MyAssembly.dll';
  • Ensure a USE [DatabaseName] statement precedes the assembly command to set the correct context explicitly.

Step 3: Validate File Paths and Permissions on Windows Server 2025

  • Confirm the DLL file path referenced in CREATE ASSEMBLY is accessible by the SQL Server service account (check C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\).
  • Verify the TRUSTWORTHY database property or CLR strict security settings are not blocking execution:
  sp_configure 'clr strict security', 1;
  RECONFIGURE;
  • Re-run the corrected script in a new query window to confirm the database context is properly set before execution.

Step 4: Update Any Automation or Deployment Scripts

  • Search deployment pipelines (PowerShell, DACPAC, or SSDT projects) for hardcoded database-prefixed assembly references.
  • Replace any instances found in .sql publish scripts or post-deployment scripts with the corrected single-part naming convention.

Alternative or Verification Steps

  • Verify the fix by querying sys.assemblies in the target database after running the corrected script — the assembly should now appear without error.
  • If the error persists, drop any partially created assembly using DROP ASSEMBLY MyAssembly; within the correct database context, then re-run the CREATE ASSEMBLY statement fresh to rule out metadata caching issues.

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

Troubleshooting Guide: SQL Server Error 1080 — “The integer value %.*ls is out of range”

Why This Error Happens

This error typically occurs when SQL Server 2025 encounters a configuration value, parameter, or registry entry that exceeds the acceptable integer boundary defined for that setting. It is commonly triggered by corrupted or manually edited configuration files, invalid startup parameters, or registry keys that were modified outside of SQL Server Configuration Manager. In some cases, this also surfaces when a legacy configuration value from a previous SQL Server version is incompatible with new boundary limits enforced in SQL Server 2025 on Windows Server 2025 / Windows 11.

Step-by-Step Resolution Guide

Step 1: Identify the Source of the Invalid Integer Value

  • Open the SQL Server Error Log located at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG to find the exact configuration key or parameter referenced alongside Error 1080.
  • Cross-reference the value with sys.configurations by running: SELECT name, value, value_in_use, maximum FROM sys.configurations;
  • Note any custom startup parameters passed via SQL Server Configuration Manager.

Step 2: Validate and Reset Registry Configuration Values

  • Open regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer
  • Inspect DWORD values for settings like AffinityMask, NetworkPacketSize, or RecoveryInterval — ensure none exceed their documented maximum range.
  • If a corrupted value is found, delete the key and allow SQL Server to regenerate it with default values on next restart.

Step 3: Reset sp_configure Values to Defaults

  • Open SQL Server Management Studio (SSMS) and run: EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
  • Identify the offending parameter and reset it: EXEC sp_configure 'parameter_name', DEFAULT; RECONFIGURE WITH OVERRIDE;
  • Restart the SQL Server service via Services.msc or net stop MSSQLSERVER && net start MSSQLSERVER.

Step 4: Rebuild Startup Parameters in Configuration Manager

  • Open SQL Server Configuration Manager → SQL Server Services → right-click the instance → Properties → Startup Parameters tab.
  • Remove any manually added -T trace flags or custom parameters that contain unusually large or malformed integer values.
  • Apply changes and restart the SQL Server service to confirm the instance starts cleanly.

Alternative or Verification Steps

  • Verify the fix by checking the Windows Event Viewer (Application Log) and confirming Error 1080 no longer appears after the service restarts successfully.
  • If the issue persists, restore the master database from a last-known-good backup, as persistent integer range errors can indicate deeper corruption in system configuration tables.

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

Why This Error Happens

Error 1079 occurs because SQL Server’s full-text search engine requires search conditions in CONTAINS or FREETEXT predicates to be resolved at compile time, not at runtime through variable substitution within a cursor context. When a cursor fetches rows and attempts to pass a column or local variable dynamically into a full-text predicate, the query optimizer cannot parameterize the full-text search condition the way it does standard T-SQL expressions. This limitation is architectural to the full-text indexing engine in SQL Server 2025 and is not related to corrupted files or missing permissions.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Cursor Logic

  • Open the stored procedure or script in SQL Server Management Studio (SSMS) and locate the DECLARE CURSOR block.
  • Check for any WHERE CONTAINS(column, @variable) or FREETEXT(column, @variable) statements inside the cursor loop.
  • Confirm the variable is being populated dynamically per row rather than being a static literal.

Step 2: Refactor to Use Dynamic SQL

  • Replace the static CONTAINS/FREETEXT call with a dynamic SQL string built using sp_executesql.
  • Example pattern:
  DECLARE @sql NVARCHAR(MAX);
  SET @sql = N'SELECT * FROM Documents WHERE CONTAINS(Content, @searchTerm)';
  EXEC sp_executesql @sql, N'@searchTerm NVARCHAR(100)', @searchTerm = @variable;
  • This bypasses the compile-time restriction by forcing the engine to treat the predicate as a freshly parsed statement on each execution.

Step 3: Eliminate the Cursor Where Possible

  • Rewrite the logic using a set-based approach with a temporary table or table variable instead of row-by-row cursor processing.
  • Use INSERT INTO #TempResults SELECT * FROM Documents WHERE CONTAINS(Content, @variable) outside the cursor, then loop through #TempResults if row-by-row processing is still required downstream.
  • This reduces both the 1079 error risk and improves query performance significantly.

Step 4: Validate Full-Text Catalog Configuration

  • Run SELECT * FROM sys.fulltext_indexes; to confirm the target table still has an active, non-corrupted full-text index.
  • On Windows Server 2025, verify the SQL Full-text Filter Daemon Launcher service is running via services.msc or Get-Service MSSQLFDLauncher.

Alternative or Verification Steps

  • Re-run the refactored procedure using sp_executesql and confirm Error 1079 no longer appears in the SSMS Messages tab or in the SQL Server Error Log (EXEC sp_readerrorlog).
  • As an alternative, if dynamic SQL is restricted by security policy, migrate the full-text logic into a parameterized inline Table-Valued Function (TVF) called from outside the cursor scope.

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

Troubleshooting Guide: SQL Server Error 1078 – “‘%.ls %.ls’ is not a recognized option”

Why This Error Happens

This error typically occurs when SQL Server 2025’s service startup parameters contain an invalid, malformed, or unrecognized switch, often introduced after a manual edit to the startup configuration or a botched in-place upgrade from a previous version. It can also surface when a legacy trace flag or startup option (deprecated in SQL Server 2025) is still being passed to sqlservr.exe via the Services console or SQL Server Configuration Manager. Additionally, corrupted registry entries under the SQL Server instance key can cause the parameter string to be parsed incorrectly, resulting in this format-string style error being thrown back from the engine.

Step-by-Step Resolution Guide

Step 1: Inspect the SQL Server Startup Parameters

  • Open SQL Server Configuration Manager (sqlservermanager16.msc or search via Start Menu on Windows 11).
  • Navigate to SQL Server Services > right-click your instance (e.g., SQL Server (MSSQLSERVER)) > Properties > Startup Parameters tab.
  • Review each parameter for typos, duplicate semicolons, or deprecated flags (e.g., old -T trace flags no longer supported in SQL Server 2025).
  • Remove any parameter that does not begin with a valid prefix (-d, -l, -e, -T, -c, etc.).

Step 2: Validate Against the Registry Directly

  • Open regedit and navigate to:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer\Parameters
  • Check keys named SQLArg0, SQLArg1, SQLArg2, etc.
  • Ensure there are no blank entries, extra spaces, or concatenated strings (e.g., -d C:\path split incorrectly across two keys).
  • Correct or delete the malformed SQLArgN key, then restart the SQL Server (MSSQLSERVER) service.

Step 3: Rebuild Startup Parameters via Command Line

  • Stop the SQL Server service: net stop MSSQLSERVER
  • Launch the engine manually with minimal parameters to isolate the bad flag:
    sqlservr.exe -c -f
  • Gradually reintroduce startup flags one at a time (e.g., -T3226, -e C:\Logs\ERRORLOG) to identify which specific option triggers Error 1078.
  • Once identified, permanently remove or correct that flag in Configuration Manager.

Step 4: Check for Upgrade Artifacts

  • If this instance was recently upgraded from SQL Server 2022, check for leftover legacy switches like -x or -g memory-to-reserve flags that may have syntax changes in the 2025 engine.
  • Run Setup.exe /ACTION=RebuildDatabase only as a last resort if parameters cannot be cleared through standard means.

Alternative or Verification Steps

  • After applying fixes, restart the SQL Server service and check the SQL Server Error Log (via C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) to confirm the service initializes without throwing Event ID 1078.
  • If the error persists, use Process Monitor (ProcMon) to trace sqlservr.exe at launch and capture the exact malformed command-line string being passed by the Windows Service Control Manager.

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

Troubleshooting Guide: Error 1077 – INSERT Into Identity Column Not Allowed on Table Variables

Why This Error Happens

This error occurs because SQL Server does not allow explicit INSERT statements that directly populate an identity column on a table variable, even when SET IDENTITY_INSERT is used elsewhere in the session. Unlike permanent tables or temporary tables, table variables have stricter scoping rules and do not support the IDENTITY_INSERT property. This typically happens when a stored procedure or script written for a regular table is mistakenly applied to a DECLARE @TableVar TABLE (...) structure containing an IDENTITY column.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Table Variable Declaration

  • Locate the DECLARE @VariableName TABLE statement in your T-SQL script or stored procedure.
  • Check if the column definition includes IDENTITY(1,1) or similar syntax.
  • Confirm the failing INSERT statement explicitly lists the identity column name in the column list (e.g., INSERT INTO @TableVar (ID, Name) VALUES (5, 'Test')).

Step 2: Remove Explicit Values for the Identity Column

  • Rewrite the INSERT statement to exclude the identity column entirely, allowing SQL Server to auto-generate the value.
  • Example: Change INSERT INTO @TableVar (ID, Name) VALUES (5, 'Test') to INSERT INTO @TableVar (Name) VALUES ('Test').
  • If you need to preserve the original ID values from a source table, add a separate non-identity column (e.g., SourceID INT) to store that reference value instead.

Step 3: Replace the Table Variable with a Temporary Table (If IDs Must Be Forced)

  • If explicit identity insertion is a business requirement, convert DECLARE @TableVar TABLE into a local temporary table using CREATE TABLE #TempTable.
  • Run SET IDENTITY_INSERT #TempTable ON before your insert statement.
  • Execute your INSERT INTO #TempTable (ID, Name) VALUES (5, 'Test') command.
  • Immediately run SET IDENTITY_INSERT #TempTable OFF after the insert completes to reset session state.

Step 4: Validate Compatibility Level in SQL Server 2025

  • Open SQL Server Management Studio (SSMS) and right-click the database in question.
  • Navigate to Properties > Options and verify the Compatibility Level is set correctly (e.g., 170 for SQL Server 2025).
  • Ensure no legacy trace flags (like 460 or 470) are forcing deprecated identity-handling behaviors that might mask the root issue.

Alternative or Verification Steps

  • To verify the fix, execute the modified script in a test environment and query the table variable or temp table using SELECT * FROM @TableVar or SELECT * FROM #TempTable to confirm the identity values incremented automatically as expected.
  • If switching to a temporary table is not feasible due to scope limitations (e.g., needing the table accessible only within a single batch), consider using a standard table-valued parameter (TVP) passed from the application layer instead, which handles ID generation downstream in the final destination table.

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

Troubleshooting Guide: SQL Server Error 1076 — “Function ‘%s’ requires at least %d argument(s)”

Why This Error Happens

This error occurs when a Transact-SQL statement calls a built-in or user-defined function without supplying the minimum number of required parameters. It is typically caused by a syntax mistake introduced during manual query edits, a faulty application update, or a schema mismatch after migrating scripts to SQL Server 2025, which has stricter parameter validation than older versions. In some cases, this surfaces after a botched deployment where a stored procedure or function definition was altered but the calling code was not updated to match.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query or Procedure

  • Open SQL Server Management Studio (SSMS) and check the SQL Server Error Log (Management > SQL Server Logs) for the exact timestamp of Error 1076.
  • Cross-reference the timestamp with Extended Events or the Query Store (Databases > YourDB > Query Store > Top Resource Consuming Queries) to pinpoint the exact statement that triggered the failure.
  • Note the function name reported in the error message (%s) and the minimum argument count (%d).

Step 2: Inspect and Correct the Function Call

  • Locate the function definition using:
  SELECT OBJECT_DEFINITION(OBJECT_ID('YourFunctionName'));
  • Compare the parameter list in the definition against the call site in your application code or stored procedure.
  • Update the calling statement to include all mandatory arguments, for example:
  SELECT dbo.YourFunction(RequiredArg1, RequiredArg2);
  • If the function is a system function (e.g., FORMAT, CONCAT, JSON_VALUE), confirm you are using the correct SQL Server 2025 syntax, as some functions had parameter requirements changed in this release.

Step 3: Validate Application and ORM Layer Code

  • Check middle-tier code (C#, Java, Python, etc.) or ORM mappings (Entity Framework, Hibernate) for dynamically generated SQL that may be omitting parameters under certain conditions (e.g., NULL-checks stripping an argument).
  • Search source control or deployment logs on the Windows Server 2025 host under C:\inetpub\wwwroot\YourApp\ or your application’s install path for recent changes to data access logic.
  • Redeploy the corrected code/stored procedure using a transactional deployment script to avoid partial updates.

Step 4: Rebuild and Test the Function Locally

  • In SSMS, use ALTER FUNCTION to redeploy the corrected function definition.
  • Run the function manually with full arguments to confirm it executes without error:
  EXEC dbo.YourFunction @Arg1 = 'Test', @Arg2 = 123;
  • Check the sys.sql_modules catalog view to ensure the updated definition was saved correctly.

Alternative or Verification Steps

  • Re-run the original failing query or trigger the application workflow that caused the error, then confirm no Error 1076 appears in the SQL Server Error Log or Windows Event Viewer (Applications and Services Logs > MSSQLSERVER).
  • If the error persists, enable SQL Server Profiler or Extended Events tracing to capture the exact runtime parameter values being passed, which can reveal conditional code paths still sending incomplete arguments.

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

Troubleshooting Guide: SQL Server Error 1075 — “RETURN Statements in Scalar Valued Functions Must Include an Argument”

Why This Error Happens

This error occurs because SQL Server’s T-SQL syntax rules require every scalar-valued function (SVF) to explicitly return a value of the declared return type via the RETURN statement. This is a compile-time parsing error (Error 1075), not a permissions or connectivity issue — it is triggered when a developer writes RETURN; with no expression, or omits the RETURN statement entirely on a code path inside a CREATE FUNCTION / ALTER FUNCTION block. Because scalar functions must always produce a single typed value, the SQL Server 2025 query parser rejects the object creation/compilation before it is ever registered in the database engine.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Function Definition

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio connected to your Windows Server 2025 / Windows 11 instance.
  • Locate the exact CREATE FUNCTION or ALTER FUNCTION script that failed — the error message in the Messages pane will reference the line number of the bad RETURN statement.
  • Run SELECT definition FROM sys.sql_modules WHERE object_id = OBJECT_ID('YourFunctionName'); if the function partially exists and you need to inspect it.

Step 2: Correct the RETURN Statement Syntax

  • Edit the function body so every RETURN includes a value matching the declared RETURNS data type, e.g.:
  CREATE FUNCTION dbo.GetTotal (@OrderId INT)
  RETURNS DECIMAL(10,2)
  AS
  BEGIN
      DECLARE @Total DECIMAL(10,2);
      SELECT @Total = SUM(LineTotal) FROM OrderDetails WHERE OrderId = @OrderId;
      RETURN ISNULL(@Total, 0);  -- must return a value, not just RETURN;
  END
  • Check all branching logic (IF, WHILE, CASE) to ensure there is no code path that hits a bare RETURN; or falls through without hitting any RETURN at all.

Step 3: Re-Deploy and Validate the Script

  • Drop and recreate the function using DROP FUNCTION IF EXISTS dbo.YourFunctionName; followed by the corrected CREATE FUNCTION statement.
  • Execute the script in a new query window to confirm it compiles with zero errors (Command completed successfully).
  • If deploying via a DACPAC/SSDT project in Visual Studio on Windows 11, rebuild the project first to catch the same error locally before publishing to the SQL Server 2025 instance.

Step 4: Audit Related Functions for the Same Pattern

  • Run a metadata search across the database to catch similar issues proactively:
  SELECT o.name, m.definition
  FROM sys.sql_modules m
  JOIN sys.objects o ON m.object_id = o.object_id
  WHERE o.type = 'FN' AND m.definition LIKE '%RETURN;%';
  • Fix any additional functions flagged by this query using the same method as Step 2.

Alternative or Verification Steps

  • Verify the fix by executing the function directly, e.g., SELECT dbo.GetTotal(1001); — a successful result set with no red error text confirms the function compiled and executes correctly.
  • If the function logic genuinely has no meaningful value to return on certain paths, use a multi-statement table-valued function (RETURNS @ReturnTable TABLE (...)) instead of a scalar function, since table-valued functions do not require a typed RETURN expression.

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

Troubleshooting Guide: SQL Server Error 1074 – “Creation of Temporary Functions Is Not Allowed”

Why This Error Happens

This error occurs when a user or application attempts to create a temporary function (e.g., using CREATE FUNCTION #FunctionName) in Microsoft SQL Server 2025, which does not support temporary user-defined functions in the same way it supports temporary tables or stored procedures. The root cause is almost always a T-SQL syntax misunderstanding or a legacy script attempting to use the # or ## prefix on a function object, rather than a missing permission or corrupted installation. In rare cases, this can also surface when a third-party ORM or migration tool generates invalid dynamic SQL against tempdb.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Review the SQL Server error log or Extended Events session for the exact statement that triggered Error 1074.
  • Look for CREATE FUNCTION # or CREATE FUNCTION ## in application code, stored procedures, or ETL scripts.
  • Check SSMS query history or the client application’s logging (e.g., Entity Framework migrations) to locate the source.

Step 2: Refactor the Code to Use Supported Objects

  • Replace the temporary function with a regular user-defined function stored in a permanent database schema (e.g., dbo.MyFunction).
  • If the intent was session-scoped logic, use a temporary table or table variable (#TempTable or @TableVar) populated by a standard function or inline query instead.
  • For reusable logic needed only within one session, consider an inline table-valued function (iTVF) created once in a utility database, rather than recreated per session.

Step 3: Validate Database Compatibility Level

  • Run the following to confirm the database compatibility level matches SQL Server 2025 expectations:
  SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
  • If the compatibility level is outdated (e.g., inherited from a restored SQL Server 2016/2019 backup), update it:
  ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;
  • This ensures the query optimizer and parser are not attempting legacy behaviors that may generate confusing errors.

Step 4: Check tempdb Configuration

  • Verify tempdb is healthy and not experiencing corruption, which can sometimes cause object-creation errors to be misreported.
  • Run:
  DBCC CHECKDB (tempdb) WITH NO_INFOMSGS;
  • Restart the SQL Server service via SQL Server Configuration Manager on Windows Server 2025 if tempdb shows inconsistent state (this rebuilds tempdb automatically).

Alternative or Verification Steps

  • After refactoring, re-run the original script or application workflow and confirm Error 1074 no longer appears in the SQL Server Error Log (Management > SQL Server Logs in SSMS).
  • As a quick verification, execute a test creation of the function using a permanent schema (CREATE OR ALTER FUNCTION dbo.TestFn...) to confirm the object creation succeeds, proving the underlying engine and permissions are functioning correctly.

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

Troubleshooting Guide: SQL Server Error 1073 — Invalid Cursor Option

Why This Error Happens

This error occurs when a T-SQL statement references a cursor option (such as FORWARD_ONLY, SCROLL, STATIC, KEYSET, or DYNAMIC) that is either misspelled, deprecated, or incompatible with the cursor type being declared. It frequently arises after migrating legacy scripts to SQL Server 2025, where certain older cursor syntax combinations are no longer parsed the same way. Additionally, corrupted or outdated client drivers (ODBC/OLE DB) on Windows Server 2025 or Windows 11 can send malformed cursor declaration requests that the Database Engine rejects.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Statement

  • Capture the exact query text using SQL Server Profiler or Extended Events (sp_server_diagnostics can help isolate the session).
  • Check the error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the full statement context tied to Error 1073.
  • Look specifically for the DECLARE CURSOR syntax used in the failing batch.

Step 2: Validate Cursor Syntax Against SQL Server 2025 Standards

  • Compare the cursor declaration against supported options: LOCAL, GLOBAL, FORWARD_ONLY, STATIC, KEYSET, DYNAMIC, FAST_FORWARD, READ_ONLY, SCROLL_LOCKS, OPTIMISTIC, TYPE_WARNING.
  • Remove any legacy or third-party options (e.g., options inherited from Sybase-style T-SQL) that are not part of the ISO syntax.
  • Rewrite ambiguous cursors using the ISO standard format instead of the Transact-SQL extended format to avoid option conflicts:
  DECLARE cursor_name CURSOR
  FOR SELECT_statement
  FOR READ ONLY

Step 3: Update Client Drivers and Connection Libraries

  • On Windows Server 2025 / Windows 11, open ODBC Data Sources (64-bit) via odbcad32.exe.
  • Verify the driver listed is ODBC Driver 18 for SQL Server or later; outdated drivers (like SQL Server Native Client) can generate malformed cursor requests.
  • Update via Microsoft Update Catalog or reinstall using:
  winget install Microsoft.ODBCDriverforSQLServer
  • Restart the application or service referencing the DSN after the update.

Step 4: Rebuild Stored Procedures with Corrected Cursor Logic

  • Use sp_helptext 'procedure_name' to extract the current procedure definition.
  • Edit and redeploy the procedure with corrected cursor syntax using ALTER PROCEDURE.
  • Recompile dependent objects with:
  EXEC sp_recompile 'procedure_name';

Alternative or Verification Steps

  • Run the corrected query manually in SQL Server Management Studio (SSMS) 20 or later and confirm it executes without raising Error 1073.
  • If the error persists, enable trace flag 7412 temporarily to capture lightweight query execution statistics and confirm the cursor is opening with the intended properties.

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

Troubleshooting Guide: SQL Server Error 1072 — REMOTE Hint Join Restriction

Why This Error Happens

This error occurs because the query optimizer only permits the REMOTE join hint when it is paired with an INNER JOIN clause. When a query attempts to use REMOTE alongside an OUTER JOIN (LEFT, RIGHT, or FULL), the SQL Server 2025 parser rejects the execution plan because remote joins rely on a specific execution strategy that cannot support outer join semantics. This is typically a T-SQL syntax/logic issue in distributed queries rather than a server configuration fault, often surfacing in linked server queries or heterogeneous distributed joins.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Open SQL Server Management Studio (SSMS) and locate the query referenced in the error stack trace or Event Viewer (Event ID 1072).
  • Search the query text for the REMOTE keyword combined with LEFT JOIN, RIGHT JOIN, or FULL JOIN.
  • Use SELECT * FROM sys.dm_exec_requests to capture the exact sql_handle if the query is still active.

Step 2: Rewrite the Join Logic

  • Convert the OUTER JOIN to an INNER JOIN if business logic allows it, since REMOTE hints are only valid there.
  • If outer join behavior is required, remove the REMOTE hint entirely and allow the optimizer to choose the join strategy automatically.
  • Alternatively, restructure the query using a derived table or CTE to isolate the inner join portion requiring the REMOTE hint, then apply the outer join logic afterward.

Step 3: Validate Linked Server Configuration

  • Navigate to Server Objects > Linked Servers in SSMS and confirm the provider settings aren’t forcing suboptimal join behavior.
  • Check sp_serveroption settings, specifically collation compatible and remote proc transaction promotion, which can influence how hints are interpreted.
  • Run EXEC sp_linkedservers; to confirm the remote data source is correctly registered and reachable.

Step 4: Test the Corrected Query in Isolation

  • Execute the modified query directly in a new SSMS query window against the production or staging environment.
  • Confirm no syntax errors are thrown and check the Actual Execution Plan to verify the REMOTE operator (if still used) appears only on inner join branches.

Alternative or Verification Steps

  • Run SET SHOWPLAN_TEXT ON; before executing the corrected query to visually confirm the join type and hint compatibility before committing to production.
  • If rewriting the join isn’t feasible, bypass the REMOTE hint entirely and let SQL Server’s cost-based optimizer handle the distributed join automatically — performance impact is usually negligible on SQL Server 2025 due to improved cross-server statistics handling.

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

Troubleshooting Guide: Error 1071 – Cannot Specify a JOIN Algorithm with a Remote JOIN

Why This Error Happens

Error 1071 occurs when a query hint such as LOOP JOIN, HASH JOIN, or MERGE JOIN is explicitly specified in a query that involves a remote JOIN operation against a linked server. SQL Server’s query optimizer cannot enforce a local join algorithm hint on a remote data source because the remote server (not the local instance) is responsible for determining its own execution plan for that portion of the query. This conflict typically arises in distributed queries, linked server calls, or queries using OPENQUERY/four-part naming conventions combined with join hints in the OPTION clause or inline hints.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query and Join Hint

  • Open SQL Server Management Studio (SSMS) and locate the query referenced in the error message or SQL Server error log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG).
  • Look for explicit join hints like INNER LOOP JOIN, INNER HASH JOIN, or INNER MERGE JOIN used alongside a four-part name (LinkedServerName.Database.Schema.Table) or OPENQUERY().
  • Confirm the remote object is indeed hosted on a linked server by running sp_linkedservers in a new query window.

Step 2: Remove or Relocate the JOIN Hint

  • Remove the explicit join algorithm hint from the T-SQL statement and allow the SQL Server Query Optimizer to choose the join strategy automatically.
  • If a specific join strategy is required, restructure the query so the remote data is pulled into a temporary table first, then apply the join hint locally:
  SELECT * INTO #RemoteData FROM OPENQUERY(LinkedServerName, 'SELECT * FROM RemoteTable');
  SELECT a.* FROM LocalTable a INNER LOOP JOIN #RemoteData b ON a.ID = b.ID;
  • Save and re-execute the modified query to confirm the hint no longer targets the remote object.

Step 3: Validate Linked Server Configuration

  • Open SSMS, navigate to Server Objects > Linked Servers, right-click the relevant linked server, and select Properties.
  • Under the Server Options tab, verify that Collation Compatible and RPC/RPC Out settings are correctly configured, as misconfigured linked servers can sometimes trigger related join-processing errors.
  • Run EXEC sp_testlinkedserver 'LinkedServerName'; in a query window to confirm connectivity before retesting the original query.

Step 4: Clear and Rebuild the Query Execution Plan Cache

  • Execute DBCC FREEPROCCACHE; to clear cached execution plans that may be referencing the invalid hint combination.
  • Re-run the corrected query and check the Actual Execution Plan (Ctrl+M in SSMS) to confirm the remote JOIN is now resolved without a local algorithm hint being pushed to the linked server.

Alternative or Verification Steps

  • Run the corrected query with SET STATISTICS PROFILE ON; to confirm Error 1071 no longer appears in the Messages tab of SSMS.
  • As an alternative, use OPENQUERY exclusively for the remote portion of the query (avoiding four-part names entirely), which forces the remote server to resolve its own execution plan and sidesteps join-hint conflicts altogether.

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

Why This Error Happens

This error occurs when a T-SQL script or application attempts to use a deprecated CREATE INDEX option that has been removed in SQL Server 2025, such as legacy PAD_INDEX, SORT_IN_TEMPDB syntax variations, or older fill-factor configurations tied to compatibility levels prior to 160. Error 1070 is specifically thrown by the Database Engine’s parser because the syntax is recognized but explicitly blocked, rather than being a generic syntax error. This typically surfaces after an in-place upgrade from SQL Server 2019/2022 or when restoring a database with a lower compatibility level onto a 2025 instance.

Step-by-Step Resolution Guide

Step 1: Identify the Deprecated Option in the Script

  • Open the failing script in SSMS or Azure Data Studio and locate the exact CREATE INDEX statement referenced in the error message (the %.*ls placeholder will show the specific option name in the actual error output).
  • Cross-reference the option against the Microsoft Docs “Deprecated Database Engine Features in SQL Server 2025” article to confirm removal status.
  • Run the following query to check the database’s current compatibility level, as this often triggers legacy parsing paths:
  SELECT name, compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';

Step 2: Update the Database Compatibility Level

  • Navigate to SSMS > Right-click Database > Properties > Options > Compatibility Level and set it to SQL Server 2025 (170).
  • Alternatively, run the T-SQL command directly:
  ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;
  • Re-run the CREATE INDEX script to see if the engine now correctly interprets the syntax under the new compatibility model.

Step 3: Rewrite the Index Creation Syntax

  • Remove the deprecated option entirely and replace it with the modern equivalent (e.g., use DATA_COMPRESSION = PAGE instead of legacy compression flags, or omit SORT_IN_TEMPDB if it has been superseded by automatic tempdb spill management).
  • Update the script path (commonly found in C:\Program Files\Microsoft SQL Server\170\Tools\Scripts\ or your custom deployment folder) to reflect the corrected syntax.
  • Save the script and validate it using SET PARSEONLY ON; before execution to catch further syntax issues without actually building the index.

Step 4: Check Linked Deployment Tools (SSDT/DACPAC)

  • If the error originates from a DACPAC deployment rather than a manual script, open the project in Visual Studio/SSDT and update the Target Platform under Project Properties to SQL Server 2025.
  • Rebuild the project to force the schema compare tool to flag any other incompatible legacy syntax before redeployment.

Alternative or Verification Steps

  • Verify the Fix: Execute the corrected CREATE INDEX statement and check sys.indexes to confirm the object was created successfully with the expected type_desc and fill_factor values.
  • Alternative Workaround: If immediate script rewriting isn’t feasible, temporarily lower the database compatibility level to 160 (SQL Server 2022) to restore legacy parsing behavior while you schedule the script remediation for a later sprint.