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

Troubleshooting Guide: SQL Server Error 8320 — @@REMSERVER Deprecation Warning

Why This Error Happens

This message is raised because @@REMSERVER is a legacy system function that Microsoft has formally marked as deprecated, meaning it is slated for removal in a future SQL Server release. SQL Server 2025 now surfaces this warning more aggressively (Error 8320) whenever the function is referenced in T-SQL batches, stored procedures, triggers, or linked server configurations. The root cause is almost always legacy code—often inherited from older SQL Server versions (2008/2012-era scripts)—that still relies on this function to identify the server name used by a client to connect, instead of using modern alternatives like SERVERPROPERTY('ServerName').

Step-by-Step Resolution Guide

Step 1: Identify All Instances of @@REMSERVER in Your Codebase

  • Run a search across your database objects using the following query to locate affected modules:
  SELECT OBJECT_NAME(object_id), definition 
  FROM sys.sql_modules 
  WHERE definition LIKE '%@@REMSERVER%';
  • Check linked server definitions, replication scripts, and legacy ETL packages (SSIS) that may also reference this function outside of standard stored procedures.
  • Review SQL Server Agent Job steps, as these are commonly overlooked sources of deprecated syntax.

Step 2: Replace Deprecated Syntax with Modern Equivalents

  • Open SQL Server Management Studio (SSMS) 21 (compatible with SQL Server 2025) and edit the identified stored procedures.
  • Replace @@REMSERVER references with SERVERPROPERTY('ServerName') or HOST_NAME(), depending on whether you need the server identity or the client workstation name.
  • Save and redeploy the updated stored procedures to your development environment first before pushing to production.

Step 3: Suppress or Monitor the Warning During Transition (Temporary Workaround)

  • If immediate code refactoring isn’t feasible, you can monitor the severity without halting execution, as Error 8320 is a warning-level event (not a blocking error).
  • Use SQL Server Configuration Manager on Windows Server 2025 to check the Error Log path (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\) and filter for Event ID 8320 to track frequency.
  • Update your SQL Server Agent alerts to flag this specific severity level so your team is notified without the application failing.

Step 4: Update Compatibility Level and Test

  • Navigate to the Database Properties in SSMS and verify the Compatibility Level is set appropriately for SQL Server 2025 (160 or higher) under the Options tab.
  • Run regression tests using the DBCC CHECKDB command alongside your application test suite to ensure removing @@REMSERVER didn’t break dependent logic.

Alternative or Verification Steps

  • To verify the fix, re-run the sys.sql_modules search query from Step 1; it should return zero rows once all instances are refactored.
  • As an alternative, if third-party vendor software is the source of the @@REMSERVER call and you cannot edit the source code, contact the vendor for a patch compatible with SQL Server 2025, or utilize a SQL Server Audit Specification to log occurrences without modifying the vendor’s binary.