Wednesday, July 07, 2010

TRUSTWORTHY SQL Database Property

I frequently come accross with Trustworthy issue when moving database from one server to another server. Enabling Trustworthy will elevate the impersonation of security.

TRUSTWORTHY { ON OFF }
ON
Database modules (for example, user-defined functions or stored procedures) that use an impersonation context can access resources outside the database.
OFF
Database modules in an impersonation context cannot access resources outside the database.
TRUSTWORTHY is set to OFF whenever the database is attached.

In SQL 2008 and SQL 2000, By default, all system databases except the msdb database have TRUSTWORTHY set to OFF.

That's the background why we may receive an error message when trying to run an existing CLR object or create an assembly that has the external_access or unsafe permission set on a database that is attached or restored from a different server

Read more information at http://support.microsoft.com/kb/918040

The value cannot be changed for the model and tempdb databases. We recommend that you never set the TRUSTWORTHY option to ON for the master database.

To set this option, we must be a member of the sysadmin fixed server role.

The status of this option can be determined by examining the is_trustworthy_on column in the sys.databases catalog view.

For example:
ALTER DATABASE AdventureWorks2008R2 SET TRUSTWORTHY ON; .

No comments: