Fix User Server Principal authentication error after db restore

use database_name; — ALTER DATABASE database_name SET READ_WRITE ——– Reset SQL user account guids ——————— DECLARE @UserName nvarchar(255) DECLARE orphanuser_cur cursor for SELECT UserName = FROM sysusers su JOIN sys.server_principals sp ON = WHERE issqluser = 1 AND (su.sid IS NOT NULL AND su.sid <> 0x0) AND suser_sname(su.sid) is null ORDER BY […]