https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-change-users-login-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/7d129880-048c-4834-a72e-c31ead4897cb/database-user-without-login?forum=sqlsecurity
DB Users which are not associated with SQL Logins will be called as Orphan ID's. You can either delete it from DB level or you can create a login in SQL and map the orphan ID with the newly created ID.
This situation will araise when you restore a database from different server (i.e from server1 to server2) where server1 will the logins associated with the db user and when you restore in server2 these logins might not exist in server2 and hence it will be an orphan ID in server2 db.
--First, make sure that this is the problem. This will lists the orphaned users:
EXEC sp_change_users_login 'Report'
--If you already have a login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user'
--If you want to create a new login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'
Check out the link below to fix the same.
--How to fix orphaned SQL Server users
https://www.fileformat.info/tip/microsoft/sql_orphan_user.htm
http://blogs.msdn.com/raulga/archive/2006/07/03/655587.aspx
--Login failures connecting to new principal after SQL Server Database Mirroring failover
https://www.mssqltips.com/sqlservertip/1166/login-failures-connecting-to-new-principal-after-sql-server-database-mirroring-failover/
SELECT
'create login [' + p.name + '] ' +
case when p.type in('U','G') then 'from windows ' else '' end +
'with ' +
case when p.type = 'S' then 'password = ' + master.sys.fn_varbintohexstr(l.password_hash) + ' hashed, ' +
'sid = ' + master.sys.fn_varbintohexstr(l.sid) +
', check_expiration = ' + case when l.is_expiration_checked > 0 then 'ON, ' else 'OFF, ' end +
'check_policy = ' + case when l.is_policy_checked > 0 then 'ON, ' else 'OFF, ' end +
case when l.credential_id > 0 then 'credential = ' + c.name + ', ' else '' end
else '' end +
'default_database = ' + p.default_database_name +
case when len(p.default_language_name) > 0 then ', default_language = ' + p.default_language_name else '' end
FROM sys.server_principals p
LEFT JOIN sys.sql_logins l ON p.principal_id = l.principal_id
LEFT JOIN sys.credentials c ON l.credential_id = c.credential_id
WHERE p.type in('S','U','G')
AND p.name <> 'sa'