If you fetched error like this
Msg 10314, Level 16, State 11, Line 4 An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error: System.IO.FileLoadException: Could not load file or assembly 'myAssembly, Version=126.96.36.1990, Culture=neutral, PublicKeyToken=5963130873dd3a75' or one of its dependencies. Exception from HRESULT: 0x80FC0E21 System.IO.FileLoadException: at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString)
then your solution can be really simple. I know that you tried to see if SQL CLR is enabled, you tried to set database THRUSTWORTHY with
ALTER DATABASE [<dbanme>] SET TRUSTWORTHY ON
but nothing worked. A magic can be in the following statement
ALTER AUTHORIZATION ON DATABASE ::[<dbanme>] TO sa;
Looks like that the problem here is that ‘dbo’ cannot be mapped to valid login, what means login with the SID equal to the the owner_sid value in sys.[databases] system view.
Why this happen?
Database owner is usually the principal who created database unless AUTHORIZATION clause was not specified, and the most times Windows SID of the database creator is used. And here is a problem when database is copied on another server by different users. Their SIDs are different.
Definitely your database can work just normally unless some component requires EXECUTE AS statement such as assembly validation, explicit EXECUTE AS in your code, code signing and service broker message delivery.
ALTER AUTHORIZATION statement just force owner_sid to a valid login of ‘sa’.