Here’s my script to fix this error. This occurs when I restore a database to another server and want to remove the source server users.
DECLARE @vcSchemaName VARCHAR(128); SET @vcSchemaName = 'schema name goes here' SELECT s.name, 'ALTER AUTHORIZATION ON SCHEMA::[' + @vcSchemaName + '] TO dbo;' FROM sys.schemas s WHERE s.principal_id = USER_ID(@vcSchemaName