Ramblings of a DBA

Tara Kizer
posts - 165, comments - 832, trackbacks - 75

My Links

Advertisement

News

Subscribe
Search this Blog

Archives

Post Categories

Work

Fix for CLR object execution error after attach/restore in SQL Server 2005

After attaching or restoring a database to SQL Server 2005, you may encounter an error when executing a CLR object. 

Error:

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65538. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE.

This KB article describes the issue and shows the fix, however it says the bug occurs when the database is attached/restored to a different SQL instance.  I’ve encountered the error three times now.  In at least one occurrence of the error, it has happened when I’ve restored the database to the same SQL instance.

Fix:

USE master
GO
ALTER DATABASE dbNameGoesHere SET TRUSTWORTHY ON

USE dbNameGoesHere
GO
EXEC sp_changedbowner 'sa'

		



		

Print | posted on Monday, September 21, 2009 10:55 AM |

Feedback

Gravatar

# re: Fix for CLR object execution error after attach/restore in SQL Server 2005

Its also noteworthy that while one backup the database containing CLR objects and restores it, the listed command needs to be executed with reference to new database in order to run/execute CLR function/s successfully

10/2/2009 1:26 PM | Nitin
Gravatar

# re: Fix for CLR object execution error after attach/restore in SQL Server 2005

Even on same instance, we need to run listed command when database is backed up
10/2/2009 1:29 PM | Nitin
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET