CLR Functions

Let’s take everything we’ve discussed about SQL CLR stored procedures and deployment and apply it to SQL CLR functions. As any programmer knows, a function is a procedure that returns a value (or an object). Mainstream .NET functions typically return .NET types. SQL CLR functions, on the other hand, must return a SqlType. So to start with, you need to make sure that your classes that implement SQL CLR functions import the System.Data.SqlTypes namespace with a using or Imports statement. The SQL Server Database Project C# template for user-defined functions (UDFs) contains the appropriate using statement by default; you will need to add the using statement manually to standard Class Library code.

Once the namespace is imported, you ...

Get Programming Microsoft® SQL Server® 2012 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.