Chapter 30
.NET Programming with SQL Server
SQL Server 2005 was the first version of this database product to host the .NET runtime. In fact, it was the first new version of Microsoft’s SQL Server product in nearly six years. It allows running .NET assemblies in the SQL Server process. Furthermore, it enables you to create stored procedures, functions, and data types with .NET programming languages such as C# and Visual Basic.
In this chapter, you learn about the following:
- Hosting the .NET runtime with SQL Server
- Classes from the namespace System.Data.SqlServer
- Creating user-defined types
- Creating user-defined aggregates
- Stored procedures
- User-defined functions
- Triggers
- XML data types
This chapter requires SQL Server 2005 or a later version of this database product.
SQL Server has many features that are not directly associated with the CLR, such as many T-SQL improvements, but they are not covered in this book. To get more information about these features you can read Wrox’s SQL Server 2005 Express Edition Starter Kit (Wiley Publishing, Inc., ISBN 0-7645-8923-7).
The samples in this chapter make use of a ProCSharp database that you can download with the code samples, and the AdventureWorks database. The AdventureWorks database is a sample database from Microsoft that you can install as an optional component with SQL Server.
.NET Runtime Host
SQL Server is a host of the .NET runtime. In versions prior to CLR 2.0, multiple hosts already existed to run .NET applications; for example, ...