In this article

Applies to:

SQL Server (all sustained versions)
Azure SQL managed Instance

Alters one assembly by editing the SQL Server directory properties of one assembly. Alter ASSEMBLY refreshes it to the recent copy of the .NET framework modules that host its implementation and also adds or clears files associated with it. Assemblies are produced by using produce ASSEMBLY.

You are watching: This server is using a modified assembly


CLR uses Code accessibility Security (CAS) in the .NET Framework, i beg your pardon is no longer supported together a defense boundary. A CLR assembly developed with PERMISSION_SET = SAFE might be maybe to access external system resources, call unmanaged code, and acquire sysadmin privileges. Start with SQL Server 2017 (14.x), one sp_configure option dubbed clr strict protection is presented to boost the security of CLR assemblies. Clr strict protection is permitted by default, and also treats SAFE and EXTERNAL_ACCESS assemblies together if castle were significant UNSAFE. The clr strict security option deserve to be disabled for backward compatibility, however this is no recommended. recommends the all assemblies be signed by a certificate or asymmetric crucial with a corresponding login that has actually been granted UNSAFE ASSEMBLY permission in the grasp database. For much more information, view CLR strictly security.

Transact-SQL Syntax Conventions


ALTER ASSEMBLY assembly_name < from | > < with < ,...n > > < DROP record all > < ADD document FROM client_file_specifier < together file_name > <,...n > > < ; > :: = "\computer_nameshare-namemanifest_file_name" | "manifest_file_name" :: = varbinary_expression :: = PERMISSION_SET = EXTERNAL_ACCESS | VISIBILITY = on | UNCHECKED DATA

To check out Transact-SQL syntax for SQL Server 2014 and also earlier, watch Previous versions documentation.


assembly_nameIs the surname of the assembly you want to modify. assembly_name must currently exist in the database.

FROM | updates an assembly come the latest copy the the .NET framework modules that organize its implementation. This option have the right to only be supplied if there are no connected files with the stated assembly.

specifies the network or local location whereby the assembly being refreshed is located. The network location contains the computer system name, the re-superstructure name and a route within the share. manifest_file_name states the surname of the file that consists of the manifest the the assembly.


Azure SQL Database go not support refereencing a file.

is the binary worth for the assembly.

Separate change ASSEMBLY statements need to be issued for any kind of dependent assemblies that additionally require updating.



The PERMISSION_SET choice is impacted by the clr strict defense option, explained in the opened warning. When clr strict defense is enabled, all assemblies room treated together UNSAFE.Specifies the .NET framework code accessibility permission collection property of the assembly. For more information around this property, see create ASSEMBLY (Transact-SQL).


The EXTERNAL_ACCESS and UNSAFE options are not easily accessible in a contained database.

VISIBILITY = turn off Indicates even if it is the assembly is visible for creating common language runtime (CLR) functions, stored procedures, triggers, user-defined types, and also user-defined aggregate functions versus it. If collection to OFF, the assembly is intended come be dubbed only by other assemblies. If there space existing CLR database objects currently created versus the assembly, the visibility that the assembly can not be changed. Any kind of assemblies referenced through assembly_name room uploaded as not visible by default.

UNCHECKED DATABy default, transform ASSEMBLY falls short if it need to verify the consistency of separation, personal, instance table rows. This option permits postponing the checks until a later time by making use of DBCC CHECKTABLE. If specified, SQL Server executes the transform ASSEMBLY statement also if there space tables in the database the contain the following:

Persisted computed columns the either straight or indirect reference methods in the assembly, v Transact-SQL functions or methods.

CHECK limit that directly or indirectly reference approaches in the assembly.

Columns the a CLR user-defined type that depend on the assembly, and the kind implements a UserDefined (non-Native) serialization format.

Columns that a CLR user-defined type that recommendation views produced by using through SCHEMABINDING.

If any CHECK constraints space present, they room disabled and significant untrusted. Any type of tables include columns depending on the assembly are significant as include unchecked data until those tables are explicitly checked.

Only members the the db_owner and db_ddlowner resolved database roles have the right to specify this option.

Requires the ALTER any SCHEMA permission come specify this option.

For much more information, watch Implementing Assemblies.

< DROP file file_name< ,...n> >Removes the paper name associated with the assembly, or all files linked with the assembly, from the database. If offered with ADD file that follows, DROP record executes first. This allows you to replace a document with the same document name.


This option is not accessible in a consisted of database or Azure SQL Database.

< ADD file FROM file_bitsAS file_nameUploads a record to be associated with the assembly, such as source code, debug records or various other related information, into the server and also made clearly shows in the sys.assembly_files brochure view. client_file_specifier specifies the location from which come upload the file. file_bits can be used instead to point out the perform of binary worths that make up the file. file_name states the name under i m sorry the paper should it is in stored in the circumstances of SQL Server. file_name must be specified if file_bits is specified, and also is optional if client_file_specifier is specified. If file_name is not specified, the file_name component of client_file_specifier is used as file_name.


This alternative is not easily accessible in a contained database or Azure SQL Database.


ALTER ASSEMBLY does not disrupt right now running sessions that are running code in the assembly being modified. Present sessions complete execution by making use of the unaltered bits of the assembly.

If the FROM clause is specified, alter ASSEMBLY update the assembly with respect come the latest copies of the modules provided. Since there might be CLR functions, stored procedures, triggers, data types, and user-defined aggregate functions in the instance of SQL Server the are currently defined versus the assembly, the change ASSEMBLY statement rebinds them to the latest implementation the the assembly. To achieve this rebinding, the approaches that map to CLR functions, save procedures, and also triggers should still exist in the amendment assembly through the exact same signatures. The classes that implement CLR user-defined types and user-defined accumulation functions must still fulfill the needs for gift a user-defined kind or aggregate.


If through UNCHECKED DATA is no specified, SQL Server tries come prevent alter ASSEMBLY from executing if the new assembly variation affects present data in tables, indexes, or various other persistent sites. However, SQL Server does no guarantee the computed columns, indexes, indexed see or expressions will be constant with the underlying routines and types when the CLR assembly is updated. Use caution once you execute change ASSEMBLY come make sure that there is not a mismatch between the an outcome of one expression and a value based upon that expression save in the assembly.

ALTER ASSEMBLY transforms the assembly version. The society and public an essential token of the assembly stay the same.

ALTER ASSEMBLY statement can not be offered to change the following:

The signatures that CLR functions, aggregate functions, save on computer procedures, and triggers in an circumstances of SQL Server that referral the assembly. Transform ASSEMBLY stops working when SQL Server cannot rebind .NET structure database objects in SQL Server v the brand-new version of the assembly.

The signatures of techniques in the assembly that are dubbed from other assemblies.

The perform of assemblies that depend on the assembly, as referenced in the DependentList property of the assembly.

The indexability the a method, uneven there are no indexes or persisted computed columns depending upon that method, either directly or indirectly.

The FillRow an approach name attribute for CLR table-valued functions.

The Accumulate and Terminate method signature because that user-defined aggregates.

System assemblies.

Additionally, for assemblies that implement user-defined types, transform ASSEMBLY deserve to be offered for making just the adhering to changes:

Modifying public methods of the user-defined type class, as lengthy as signatures or attributes are no changed.

Adding brand-new public methods.

Modifying private methods in any type of way.

Fields had within a native-serialized user-defined type, including data members or basic classes, cannot be readjusted by using transform ASSEMBLY. All other changes are unsupported.

If ADD file FROM is not specified, change ASSEMBLY drops any kind of files linked with the assembly.

If transform ASSEMBLY is executed without the UNCHECKED data clause, checks room performed to verify the the brand-new assembly version does not influence existing data in tables. Relying on the amount of data that demands to it is in checked, this may influence performance.


Requires alter permission ~ above the assembly. Additional requirements room as follows:

To transform an assembly who existing permission collection is EXTERNAL_ACCESS, requiresEXTERNAL accessibility ASSEMBLYpermission ~ above the server.

To change an assembly who existing permission set is UNSAFE calls for UNSAFE ASSEMBLY permission on the server.

To adjust the permission set of an assembly come EXTERNAL_ACCESS, requiresEXTERNAL access ASSEMBLY permission top top the server.

To change the permission set of an assembly come UNSAFE, calls for UNSAFE ASSEMBLY permission on the server.

Specifying with UNCHECKED DATA, requires ALTER any kind of SCHEMA permission.

Permissions with CLR strictly security

The adhering to permissions forced to transform a CLR assembly once CLR strict security is enabled:

The user must have the transform ASSEMBLY permissionAnd among the following conditions must also be true:The assembly is signed with a certificate or asymmetric vital that has a corresponding login with the UNSAFE ASSEMBLY permission top top the server. Signing the assembly is recommended.The database has actually the trustworthy property set to ON, and also the database is own by a login that has the UNSAFE ASSEMBLY permission ~ above the server. This option is not recommended.

For more information about assembly permission sets, see creating Assemblies.


A. Update an assembly

The following instance updates assembly ComplexNumber come the recent copy the the .NET framework modules that organize its implementation.


Assembly ComplexNumber deserve to be created by running the UserDefinedDataType sample scripts. For more information, see User characterized Type.

ALTER ASSEMBLY ComplexNumber from "C:Program SQL Server130ToolsSamples1033EngineProgrammabilityCLRUserDefinedDataTypeCSComplexNumberobjDebugComplexNumber.dll"

B. Adding a record to associate through an assembly

The following example uploads the source code paper Class1.cs come be linked with assembly MyClass. This example assumes assembly MyClass is already created in the database.

See more: Movie Theaters In Glen Burnie Md, Glen Burnie Mall Theatre

ALTER ASSEMBLY MyClass ADD paper FROM "C:MyClassProjectClass1.cs";

C. Changing the permissions of an assembly

The complying with example alters the permission set of assembly ComplexNumber from safe to exterior ACCESS.


See Also