Troubleshooting Guide: SQL Server Error 3815 — Invalid Linked Login Mapping
Why This Error Happens
This error occurs when a local SQL Server login is mapped to a linked server login that no longer resolves correctly, often due to a SID mismatch, a dropped remote login, or corrupted metadata in sys.linked_logins. During a Microsoft SQL Server 2025 upgrade, the setup process validates all linked server login mappings, and any orphaned or inconsistent mapping (where the remote login referenced does not match what’s stored in the system catalog) will halt the upgrade with Error 3815. This is common after restoring databases across instances, renaming logins, or when a linked server’s remote login was manually altered without updating the mapping.
Step-by-Step Resolution Guide
Step 1: Identify the Affected Linked Server and Login Mapping
- Open SQL Server Management Studio (SSMS) and connect to the instance reporting the error.
- Run the following query to list all linked logins and their mappings:
SELECT ll.name AS local_login, s.name AS linked_server, ll.remote_name
FROM sys.linked_logins ll
JOIN sys.servers s ON ll.server_id = s.server_id;
- Cross-reference the
local_loginandlinked_servernames mentioned in the Error 3815 message with this output.
Step 2: Drop the Invalid Linked Login Mapping
- Use
sp_droplinkedsrvloginto remove the broken mapping before attempting any recreation:
EXEC sp_droplinkedsrvlogin
@rmtsrvname = N'YourLinkedServerName',
@locallogin = N'YourLocalLoginName';
- If the local login value was
NULL(mapped generically), passNULLexplicitly for@locallogin. - Confirm removal by re-running the query from Step 1 — the row should no longer appear.
Step 3: Recreate the Linked Login with Valid Credentials
- Re-establish the mapping using
sp_addlinkedsrvlogin, ensuring the remote login and password are current and valid on the target server:
EXEC sp_addlinkedsrvlogin
@rmtsrvname = N'YourLinkedServerName',
@useself = N'FALSE',
@locallogin = N'YourLocalLoginName',
@rmtuser = N'ValidRemoteUser',
@rmtpassword = N'ValidRemotePassword';
- Verify the remote login actually exists and is enabled on the linked instance (check
sys.server_principalson the target server).
Step 4: Re-run the SQL Server 2025 Upgrade/Setup
- Navigate to the SQL Server 2025 setup media or
C:\SQLServer2025Media\setup.exe. - Launch the upgrade wizard again and allow the “Rule Check” phase to re-validate linked server logins.
- Confirm the Error 3815 rule no longer flags a failure before proceeding to the “Ready to Install” step.
Alternative or Verification Steps
- Verify the fix: After recreating the mapping, run
EXEC sp_helplinkedsrvlogin;(or querysys.linked_loginsagain) to confirm the local-to-remote login pairing is intact, then re-test connectivity usingEXEC sp_testlinkedserver 'YourLinkedServerName';. - Alternative fix: If the linked server itself is obsolete or no longer needed, instead of recreating the login, simply drop the entire linked server object with
EXEC sp_dropserver 'YourLinkedServerName', 'droplogins';— this removes both the server and its associated login mappings in one step, clearing the upgrade blocker.