O'Reilly logo

Programming Microsoft® SQL Server™ 2008 by Leonard Lobel, Andrew Brust, and Stephen Forte

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, we need to make sure that our classes that implement SQL CLR functions import the System.Data.SqlTypes namespace with a using statement. The SQL Server Project template for User-Defined Functions contains the appropriate using statement by default; you will need to add the statement manually to standard Class Library class code.

Once the namespace is imported, you can write the functions themselves. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required