Common Language Runtime (CLR) 整合程式設計概念Common Language Runtime (CLR) Integration Programming Concepts

適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance適用範圍:Applies to: 是SQL ServerSQL Server (所有支援的版本) yesSQL ServerSQL Server (all supported versions) 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance

SQL Server 2005 (9.x)SQL Server 2005 (9.x) 開始,SQL ServerSQL Server 具備 .NET Framework for MicrosoftMicrosoft Windows 的 Common Language Runtime (CLR) 元件整合功能。Beginning with SQL Server 2005 (9.x)SQL Server 2005 (9.x), SQL ServerSQL Server features the integration of the common language runtime (CLR) component of the .NET Framework for MicrosoftMicrosoft Windows. 這表示您現在可以使用任何 .NET Framework 語言 (包括 MicrosoftMicrosoft Visual Basic .NET 及 MicrosoftMicrosoft Visual C#),撰寫預存程序、觸發程序、使用者定義型別、使用者定義函數、使用者定義彙總及資料流資料表值函數。This means that you can now write stored procedures, triggers, user-defined types, user-defined functions, user-defined aggregates, and streaming table-valued functions, using any .NET Framework language, including MicrosoftMicrosoft Visual Basic .NET and MicrosoftMicrosoft Visual C#.

Microsoft.SqlServer.Server 命名空間在 SQL ServerSQL Server 中包含用於 CLR 程式設計的核心功能。The Microsoft.SqlServer.Server namespace includes core functionality for CLR programming in SQL ServerSQL Server. 不過,Microsoft.SqlServer.Server 命名空間會記載在 .NET Framework SDK 中。However, the Microsoft.SqlServer.Server namespace is documented in the .NET Framework SDK. 此文件不包含在《SQL ServerSQL Server 線上叢書》中。This documentation is not included in SQL ServerSQL Server Books Online.

重要

根據預設,.NET Framework 會與 SQL ServerSQL Server 一起安裝,但是 .NET Framework SDK 則不會。By default, the .NET Framework is installed with SQL ServerSQL Server, but the .NET Framework SDK is not. 如果 SDK 未安裝在電腦上,也不包含在線上叢書集合中,本節中的 SDK 內容連結將不會有任何作用。Without the SDK installed on your computer and included in the Books Online collection, links to SDK content in this section do not work. 請安裝 .NET Framework SDK。Install the .NET Framework SDK. 安裝之後,請遵循安裝 .NET FRAMEWORK sdk中的指示,將 SDK 新增至線上叢書集合和目錄。Once installed, add the SDK to the Books Online collection and table of contents by following the instructions in Installing the .NET Framework SDK.

注意

Azure SQL Database支援 clr 功能(例如 clr 使用者函數)。CLR functionality, such as CLR user functions, are not supported for Azure SQL Database.

下表列出本節的主題。The following table lists the topics in this section.

Common Language Runtime (CLR) 整合總覽Common Language Runtime (CLR) Integration Overview
提供 CLR 的簡短概觀,並描述在 SQL ServerSQL Server 中使用此技術的方法和原因。Provides a brief overview of the CLR, and describes how and why this technology has been used in SQL ServerSQL Server. 描述使用 CLR 建立資料庫物件的優點。Describes the benefits of using the CLR to create database objects.

組件 (Database Engine&#41Assemblies (Database Engine)
描述如何使用組件在 SQL ServerSQL Server 中部署以 MicrosoftMicrosoft .NET Framework Common Language Runtime (CLR) 主控的其中一種 Managed 程式碼語言 (非 Transact-SQLTransact-SQL) 所編寫的函數、預存程序、觸發程序、使用者定義彙總,以及使用者定義型別。Describes how assemblies are used in SQL ServerSQL Server to deploy functions, stored procedures, triggers, user-defined aggregates, and user-defined types that are written in one of the managed code languages hosted by the MicrosoftMicrosoft .NET Framework common language runtime (CLR), and not written in Transact-SQLTransact-SQL.

使用 Common Language Runtime 建立資料庫物件 (CLR) 整合Building Database Objects with Common Language Runtime (CLR) Integration
描述可以使用 CLR 建立的物件種類,並檢閱建立 CLR 資料庫物件的需求。Describes the kinds of objects that can be built using the CLR, and reviews the requirements for building CLR database objects.

從 CLR 資料庫物件進行資料存取Data Access from CLR Database Objects
描述 CLR 常式如何存取儲存在 SQL ServerSQL Server 執行個體中的資料。Describes how a CLR routine can access data stored in an instance of SQL ServerSQL Server.

CLR 整合安全性CLR Integration Security
描述 CLR 整合的安全性模型。Describes the CLR integration security model.

偵錯 CLR 資料庫物件Debugging CLR Database Objects
描述為 CLR 資料庫物件偵錯的限制和需求。Describes limitations of and requirements for debugging CLR database objects.

部署 CLR 資料庫物件Deploying CLR Database Objects
描述如何將組件部署至實際伺服器。Describes deploying assemblies to production servers.

管理 CLR 整合組件Managing CLR Integration Assemblies
描述如何建立和卸除 CLR 整合組件。Describes how to create and drop CLR integration assemblies.

監視與疑難排解 Managed 資料庫物件Monitoring and Troubleshooting Managed Database Objects
提供可用於監視和疑難排解 Managed 資料庫物件以及在 SQL ServerSQL Server 中執行之組件的工具相關資訊。Provides information about the tools that can be used to monitor and troubleshoot managed database objects and assemblies running in SQL ServerSQL Server.

通用語言執行平台 (CLR) 整合的使用案例和範例Usage Scenarios and Examples for Common Language Runtime (CLR) Integration
描述使用 CLR 物件的使用狀況和程式碼範例。Describes usage scenarios and code samples using CLR objects.

另請參閱See Also

元件 (資料庫引擎) Assemblies (Database Engine)
安裝 .NET Framework SDKInstalling the .NET Framework SDK