Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 3.75 KB

csharp-overview.md

File metadata and controls

51 lines (36 loc) · 3.75 KB
title titleSuffix description author ms.author ms.date ms.service ms.subservice ms.topic ms.custom monikerRange
What is the C# Language Extension?
SQL Server Language Extensions
The C# Language Extension is a feature of SQL Server used for executing external C# code. Relational data can be used in the external C# code using the extensibility framework.
rwestMSFT
randolphwest
04/29/2024
sql
language-extensions
overview
intro-overview
>=sql-server-ver15 || >=sql-server-linux-ver15

What is the C# Language Extension?

[!INCLUDE sqlserver2019-and-later]

The C# Language Extension is a feature of SQL Server Language Extensions that can be used for executing C# code within SQL Server. You can pass an existing SQL Server table to a C# application as a DataFrame, perform operations in C# using rich libraries, and obtain back a result set. This C# language extension allows you to reuse existing C# code, calculations, logic, or extensive libraries that provide functionality you can't get in Transact-SQL (T-SQL).

The external C# language is defined with CREATE EXTERNAL LANGUAGE. The system stored procedure sp_execute_external_script is used as the interface for executing the C# code.

Note

The C# language extension is compatible with [!INCLUDE sssql19-md] CU 3 and later versions. Currently, it integrates .NET Core on SQL Server for Windows only. Linux isn't supported.

What you can do

The C# language extension uses the extensibility framework for executing external C# code. Code execution is isolated from the core engine processes, but fully integrated with SQL Server query execution. You can execute C# code at the data's source, eliminating the need to pull data across the network.

You can do data cleaning, fast data querying, or any other processing in C# that can occur through a DataFrame. By embedding C# code in stored procedures, you can push business logic down into the database for better performance. This helps avoid unnecessary data movement and latency, because data doesn't need to be retrieved from SQL Server and moved into the app tier to do the business logic processing.

Get started

  1. Install SQL Server .NET Language Extension on Windows.

  2. Configure development tools.

  3. Write your first C# code. Use the following tutorial as a starting point. Tutorial: Search for a string using regular expressions (regex) in C#.

Related content