Skip to content

Instantly share code, notes, and snippets.

@q42jaap
Created October 17, 2012 11:56
Show Gist options
  • Save q42jaap/3905150 to your computer and use it in GitHub Desktop.
Save q42jaap/3905150 to your computer and use it in GitHub Desktop.
Login corrupted after database backup restore from different server
USE dbname;
SELECT s.name
FROM sys.schemas s
WHERE s.principal_id = USER_ID('username');
ALTER AUTHORIZATION ON SCHEMA::db_owner TO dbo;
-- from http://blog.sqlauthority.com/2011/12/26/sql-server-fix-error-15138-the-database-principal-owns-a-schema-in-the-database-and-cannot-be-dropped/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment