Chapter 7

SQL Server CLR Integration


  • How the CLR is Implemented in SQL Server
  • SQLCLR Assembly Creation and Deployment
  • Securing SQLCLR Assemblies
  • Performance

SQL Server developers first saw the integration of the .NET Common Language Runtime (CLR) with the release of SQL Server 2005. Not a whole lot has changed with the release of SQL Server 2008 and 2012. Yet, SQLCLR provides great benefits to developers as well as database administrators, and is worth reviewing.

This chapter does not focus entirely on how to write SQLCLR .NET assemblies, (visit for a more in-depth discussion of that) but does provide a few examples on how to create and deploy an assembly. These serve as a nice foundation on which to focus the majority of the chapter, which covers SQLCLR Administration. This chapter focuses on the CLR as a hosted environment in SQL Server and discusses why you would use T-SQL over a SQLCLR solution. This chapter also discusses SQLCLR performance and security because these are critical concepts to consider when deciding to use SQLCLR.


With the integration of the .NET Framework CLR components in SQL Server, developers have the flexibility to write stored procedures, triggers, user-defined types and functions, and streaming table-valued functions using a variety of .NET Framework languages, the most common being C# and Visual Basic .NET. It’s no secret that this addition ...

Get Professional Microsoft SQL Server 2012 Administration now with O’Reilly online learning.

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