title: Republishing a SQL Server CLR assembly using Visual Studio
body: <p>I created a CLR assembly with several utility functions and published it to SQL Server 2012 using Visual Studio 2015.  Everything worked.  </p>
  
  <p>I wanted to change the input parameter for a particular function from <code>int?</code> to <code>long?</code>.  I made that change, rebuilt the project and republished it, but the changed CLR assembly was not replaced.</p>
  
  <p>I tried dropping the function from T-SQL:</p>
  
  <pre><code>drop function myFunc
  </code></pre>
  
  <p>and it was successfully dropped from the database. Then I republished again from Visual Studio, but now the function is simply gone from the database. It was not replaced by the republish.</p>
  
  <p>I tried dropping the assembly but the drop failed with the error that 'myAssemblyName' was referenced by object 'foo', one of the functions in the assembly.</p>
  
  <p>Is there a built-in feature in Visual Studio that handles the necessary housekeeping tasks on the server when making selective updates to individual items in an assembly? Do these steps have to be done "manually" in T-SQL outside of Visual Studio?</p>
  
  <p>Edit:</p>
  
  <p>I looked at the install script and the section where work was done was blank. I don't know why. So I changed the project from <code>Any CPU</code> to <code>x64</code> and rebuilt and republished, and then everything was working again.</p>
  
  <pre><code>&lt;snip&gt;
  :setvar __IsSqlCmdEnabled "True"
  GO
  IF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
      BEGIN
          PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
          SET NOEXEC ON;
      END
  
  
  GO
  USE [$(DatabaseName)];
  
  
  GO
  PRINT N'Update complete.';
  </code></pre>