Microsoft SQL Server 2008 R2 Unleashed- P188:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | This page intentionally left blank CHAPTER 46 SQLCLR Developing SQL Server Objects in .NET IN THIS CHAPTER What s New for SQLCLR in SQL Server 2008 Developing Custom Managed Database Objects T his chapter examines the deep integration of the .NET Framework with SQL Server 2008. It delves into SQL Server 2008 s support for the creation of custom managed database objects otherwise known as SQLCLR. What s New for SQLCLR in SQL Server 2008 Although there are only a few changes to SQLCLR in SQL Server 2008 including support for multiparameter aggregates support for large-value data types such as nvarchar MAX and support for the new SQL Server 2008 data types such as date and time SQLCLR itself introduces a wealth of new possibilities for developing with .NET and SQL Server that you should consider leveraging in your data-driven applications. In the following sections we give you all the tools you need to write your own stored procedures functions triggers data types and aggregate functions in C or VB .NET. Developing Custom Managed Database Objects SQL Server 2008 hosts the common language runtime CLR implementing what s known as the Hosting API. The Hosting API gives SQL Server 2008 full control over the execution of .NET code in a carefully managed environment that honors the shared resource usage of both SQL Server and the CLR. The CLR provides an execution context far 1826 CHAPTER 46 SQLCLR Developing SQL Server Objects in .NET safer than that of code you might formerly have run in an extended stored procedure or COM object under SQL Server 2000 and previous editions. In the sections that follow you will create one of each of the managed versions of database routines and types. You work with both the SQL Server project type in Visual Studio 2008 as well as the T-SQL Data Definition Language DDL syntax for managed objects. Finally you ll learn about advanced topics such as transaction control in mixed T-SQL and managed environments. An Introduction to Custom Managed