Friday, January 27, 2012

CLR Stored Proc with Output Value Returning NULL

I'm a little embarrassed to be writing a post about this but I figured there might be someone else out there making the same obvious mistake that might find this useful.

I recently created a CLR stored procedure that returns a value. Not a return code but an actual calculated output. To implement this in C# it is necessary to declare an output parameter in the method definition similar to the following.


public static void CLRSum(SqlInt32 val1, SqlInt32 val2, out SqlInt32 value)
{
   value = val1 + val2
}

As I alluded to in the title of this post, calls to my new CLR stored procedure where returning NULL. Below is how I was calling my CLR stored procedure from T-SQL.
DECLARE @value INT
EXECUTE dbo.CLRSum 4, 3, @value 
SELECT @Value

Notice anything missing? Took me a little while but I finally realized I was missing the output keyword. The correct way to call the stored proc is below.
DECLARE @value INT
EXECUTE dbo.CLRSum 4, 3, @value output
SELECT @Value

Wednesday, January 11, 2012

The specified program requires a newer version of Windows - SSDT Install

Look familiar?



Unfortunately SSDT is not supported on Windows XP. The following Windows versions are supported.

  1. Windows Vista SP2 or higher
  2. Windows Server 2008 SP2 or higher
  3. Windows 7 RTM or higher
  4. Windows Server 2008 R2 RTM or higher