When I try to install tSQLt onto an existing database i get the following error:
The database owner SID recorded in the master database differs from the database owner SID recorded in database ''. You should correct this situation by resetting the owner of database '' using the ALTER AUTHORIZATION statement.
When want to import a new clr if you got this error message just set Sa as owner for your databse like below so should be work
Alter Authorization on Database::[] to [sa]
Added this to the top of the tSQLt.class.sql script
This problem can arise when a database restored from a backup and the SID of the database owner does not match the owners SID listed in the master database. Here is a solution that uses the "ALTER AUTHORIZATION" statement recommended in the error message:
I ran into this issue as well, and found that the Owner of the target database didn't exist in the master database. Mapping that user to the master database resolved the issue for me.
Apply the below script on database you get the error:
Necromaning:
If you don't want to use the SQL-Server 2000 views (deprecated), use this:
Also prevents bug on oddly named database or user, and also fixes bug if no user is associated (uses sa login).