‘Unsafe assembly’, CLR errors in SQL logs and solution script

This problem occurs because the login that you use to create the database on Server A is not in the instance of SQL Server 2005 on Server B. This login could be either the Microsoft Windows login or the SQL Server login.
What you need to do is to change the owner of database(s) to ‘SA’ if not so.
Following script with database owner changing script for all the databases that need this change leaving out System, readonly databases and also the ones where SA is already set as the owner

select 'use [' + name + '] EXEC sp_changedbowner sa' , 
owner_sid   ,  is_read_only from sys.databases
	where is_read_only =0 and database_id >4 and owner_sid <> 0x01

Once the script is generated. Go through the list and then apply it to the ones where applicable and known to not cause any issues. Such as in the case where this required for a valid technical reason including requirement from software vendors.

IT professional with wider interest in technology

Tagged with: ,
Posted in sql, tsql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: