Troubleshooting Guide: Error 4128 — Internal Error During Remote Query Execution
Why This Error Happens
Error 4128 typically occurs when SQL Server 2025 encounters a breakdown in communication between the local instance and a linked server during distributed query execution. This is most commonly caused by outdated or mismatched OLE DB providers, corrupted linked server metadata, or insufficient permissions on the remote data source. It can also surface when the remote query optimizer receives malformed or incompatible T-SQL syntax that the remote provider cannot translate correctly.
Step-by-Step Resolution Guide
Step 1: Verify Linked Server Configuration
- Open SQL Server Management Studio (SSMS) and navigate to Server Objects > Linked Servers.
- Right-click the linked server and select Properties to confirm the provider, data source, and security context are correct.
- Run the following to test connectivity:
EXEC sp_testlinkedserver 'YourLinkedServerName';
Step 2: Update or Reinstall the OLE DB Provider
- Navigate to
C:\Program Files\Microsoft SQL Server\160\Shared(or the relevant version path) and confirm the provider DLL (e.g.,msoledbsql.dll) is not corrupted. - Download and reinstall the latest Microsoft OLE DB Driver for SQL Server from the official Microsoft Download Center.
- Restart the SQL Server service via Services.msc or run:
Restart-Service -Name 'MSSQLSERVER'
Step 3: Check Permissions and Security Context
- Ensure the login used for the remote connection has appropriate
db_datareaderanddb_datawriterroles on the target database. - Validate the “Be made using this security context” setting under linked server properties includes a valid remote login and password.
- Confirm firewall rules on both Windows Server 2025 instances allow traffic on port 1433 (or your custom SQL port).
Step 4: Rebuild Linked Server Metadata
- Drop and recreate the linked server definition using:
EXEC sp_dropserver 'YourLinkedServerName', 'droplogins';
EXEC sp_addlinkedserver 'YourLinkedServerName', 'SQL Server';
- Reapply any necessary login mappings using
sp_addlinkedsrvlogin.
Alternative or Verification Steps
- Run a simple test query such as
SELECT * FROM [YourLinkedServerName].[DatabaseName].[dbo].[TableName]to confirm the error no longer appears. - If the issue persists, enable SQL Server Profiler or Extended Events to capture the exact failing remote query and check the SQL Server Error Log for additional context codes accompanying Error 4128.