Why This Error Happens
This error occurs because SQL Server 2025 attempts to load an Extended Stored Procedure (XP) DLL that was compiled for a legacy or incompatible version of Open Data Services (ODS), and the DLL lacks the required __GetXpVersion() export function. SQL Server uses this function as a version-handshake mechanism to verify the DLL is compatible with the current server’s calling conventions before execution. Since Microsoft deprecated full support for legacy Extended Stored Procedures in favor of CLR integration and native external libraries, any DLL built against pre-2016 ODS headers (or third-party XP DLLs not recompiled since) will fail this compatibility check on Windows Server 2025 / Windows 11 hosts.
Step-by-Step Resolution Guide
Step 1: Identify the Offending DLL and Procedure
- Check the SQL Server Error Log (
ERRORLOG) or Windows Event Viewer (Application Log, Source: MSSQLSERVER) for the exact%sDLL name reported alongside Error 8131. - Run the following query to cross-reference which extended stored procedure maps to that DLL:
SELECT name, dll FROM sys.extended_procedures;
- Note the full file path, typically located in
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\.
Step 2: Verify DLL Compatibility and Source
- Confirm whether the DLL was built in-house or sourced from a third-party vendor.
- If third-party, check the vendor’s website for a version compiled specifically for SQL Server 2022/2025 or one that supports the modern ODS calling convention.
- If custom-built, open the source project and confirm it links against the updated
opends60.h/srv.hheaders shipped with the SQL Server 2025 Native Client SDK.
Step 3: Recompile or Replace the Extended Stored Procedure DLL
- Recompile the DLL using Visual Studio 2022 (or later) targeting the x64 platform, ensuring the project explicitly implements and exports
__GetXpVersion()alongside__GetXpVersion()andsrv_prochandlers. - Example minimal export in your DLL’s
.deffile:
EXPORTS
__GetXpVersion
xp_yourprocname
- Copy the updated DLL into the
Binndirectory, replacing the outdated file.
Step 4: Re-register the Extended Stored Procedure
- Drop and re-add the procedure to force SQL Server to reload the DLL metadata:
EXEC sp_dropextendedproc 'xp_yourprocname';
GO
EXEC sp_addextendedproc 'xp_yourprocname', 'yourdll.dll';
GO
- Restart the SQL Server (MSSQLSERVER) service via
services.mscornet stop/start MSSQLSERVERto clear any cached module handles.
Step 5: Consider Migrating Away from Extended Stored Procedures
- Since XPs are deprecated, evaluate migrating the logic to a SQLCLR assembly or an external REST/API call via
sp_invoke_external_rest_endpoint(available in SQL Server 2025), which avoids this compatibility layer entirely.
Alternative or Verification Steps
- Verify the fix by executing the procedure manually (
EXEC xp_yourprocname) and confirming no 8131 error appears in the ERRORLOG. - If recompiling isn’t feasible, as a temporary workaround, run the legacy DLL on a separate SQL Server 2016/2017 instance and link via Linked Server, until a compatible native replacement is available.