Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I update an assembly and its dependent assemblies in MS-SQL?

This is the situation:

I have a Trigger.dll and a Trigger.XmlSerializer.dll.

I use CREATE ASSEMBLY to register them in MSSQL.

Now, I have compiled new versions of both.

I want to use ALTER ASSEMBLY to update them, however you can only update one at a time. If you try to update one that has a dependency, it complains. What's the trick to doing this?

I don't want to drop and recreate as I have to then drop all the triggers, etc. and there is database downtime.

like image 394
Chris KL Avatar asked Feb 05 '09 03:02

Chris KL


People also ask

Where are assemblies stored in SQL Server?

Deployed User CLR assemblies are stored in the database you deploy them to, not on the file system. the column called content contains binary data is the assembly.

How can check CLR assembly permission set in SQL Server?

To determine if CLR is enabled, execute the following commands: EXEC SP_CONFIGURE 'show advanced options', '1'; RECONFIGURE WITH OVERRIDE; EXEC SP_CONFIGURE 'clr enabled';

What is SQL CLR assemblies?

NET Framework common language runtime (CLR), instead of in Transact-SQL. An assembly in SQL Server is an object that references a managed application module (. dll file) that was created in the . NET Framework common language runtime. An assembly contains class metadata and managed code.


2 Answers

according to the microsoft support you can use it by trick.

Notes

  • These steps upgrade or downgrade assembly A in the scenario that was described in the "How to upgrade or downgrade an assembly" section.
  • This example assumes that the versions of the two assemblies are both 1.0.0.0 and the assemblies are both written in C#. When you follow these steps, you try to upgrade assembly A and assembly B to version 2.0.0.0.

To upgrade or downgrade assembly A, follow these steps.

  1. Back up version 1.0.0.0 of assembly B to a folder.
  2. Modify and then recompile assembly B to version 2.0.0.0.
  3. Use the ALTER ASSEMBLY statement to upgrade assembly B in SQL Server 2005.
  4. Modify and then recompile assembly A to version 2.0.0.0. When you do this, reference version 1.0.0.0 of assembly B from the backup that you made in step 1. To do this, use the Csc.exe compiler tool together with the /reference switch. For example, use the following command: csc /target:library /out:AssemblyA.dll AssemblyA.cs AssemblyInfo.cs /reference:"BackupFolder\AssemblyB.dll" Note To verify the version of assembly B in the metadata of assembly A, open assembly A by using the Ildasm.exe utility. Then, verify the metadata information for the referenced assembly under the MANIFEST section.
  5. Use the ALTER ASSEMBLY statement to upgrade assembly A in SQL Server 2005.
like image 108
Avram Avatar answered Oct 04 '22 01:10

Avram


I fear dropping the table and re-creating it is the only way.

The main reason for this is that values stored in a type in an assembly, are unusable if you update the assembly to a new version.

like image 37
Frans Bouma Avatar answered Oct 04 '22 01:10

Frans Bouma