Last updated: August 28, 2026.
A database user can remain after its server login is missing or has a different SID. This often appears after restoring a database on another instance.
Report and repair the mapping
USE YourDatabase;
GO
SELECT dp.name AS DatabaseUser, dp.sid
FROM sys.database_principals AS dp
LEFT JOIN sys.server_principals AS sp ON dp.sid = sp.sid
WHERE dp.authentication_type_desc = 'INSTANCE'
AND dp.type IN ('S','U','G')
AND sp.sid IS NULL;
GO
ALTER USER [AppUser] WITH LOGIN = [AppLogin];Verify before changing
- Confirm that the login represents the same identity.
- Create the login first when it is truly missing.
- Review role membership and explicit grants.
- Test application access with least privilege.
Reference: Microsoft ALTER USER documentation.