title: How can I use the SqlFunctionAttribute in a database project to generate the SQL to deploy the functions myself? Visual studio fails
body: <p><strong>Background:</strong></p>
  
  <p>Visual studio fails at deploying a database project.  It tries to drop functions that are already referenced (e.g. in a check constraint), rather than just adding the new ones and updating the existing ones, so the deployment always fails.</p>
  
  <p>As a result, I'm writing my own code to update the assembly and add/update any functions.</p>
  
  <p>I assume the compiler/deployer uses reflection and properties of the SqlFunction attribute, so I'm also using reflection to gather a MethodInfo list of the static methods that have the SqlFunction attribute.</p>
  
  <p><strong>Question/Task:</strong></p>
  
  <p>I need to know how to translate the SqlFunctionAttribute's properties (e.g. IsDeterministic, DataAccess, Name, IsPrecise, etc.) and the method signature of the function into an appropriate T-SQL "CREATE FUNCTION" statement.</p>
  
  <p><strong>Existing information I've already found to be not helpful:</strong></p>
  
  <p>The <a href="http://msdn.microsoft.com/en-us/library/ms186755.aspx" rel="nofollow noreferrer">documentation</a> for 'create function' is confusing and incomplete.  Towards the bottom it finally mentions some of the SqlFunction properties like IsDeterministic, but it talks about them like they're C# properties, not T-SQL parameters, so I have no idea how to use them in a create function statement.</p>
  
  <pre><code>//CLR Functions
  CREATE FUNCTION [ schema_name. ] function_name 
  ( { @parameter_name [AS] [ type_schema_name. ] parameter_data_type 
          [ = default ] } 
      [ ,...n ]
  )
  RETURNS { return_data_type | TABLE &lt;clr_table_type_definition&gt; }
      [ WITH &lt;clr_function_option&gt; [ ,...n ] ]
      [ AS ] EXTERNAL NAME &lt;method_specifier&gt;
  [ ; ]
  </code></pre>
  
  <p>I would expect the <code>clr_function_option</code> parameter to handle things like IsDeterministic, but it's not listed as an option.</p>
  
  <p>Meanwhile, in documentation for IBM DB2, I see statements like the following, which the MSDN documentation has nothing remotely similar:</p>
  
  <pre><code>  CREATE FUNCTION countUp(INTEGER) 
    RETURNS INTEGER
    LANGUAGE CLR
    PARAMETER STYLE SQL
    SCRATCHPAD 10
    FINAL CALL
    NO SQL
    FENCED
    THREADSAFE
    NOT DETERMINISTIC
    EXECUTION CONTORL SAFE
    EXTERNAL NAME 'gwenUDF.dll:bizLogic.empOps!CountUp' ;
  </code></pre>