Microsoft.SqlServer.Server
1.0.0
Prefix Reserved
dotnet add package Microsoft.SqlServer.Server --version 1.0.0
NuGet\Install-Package Microsoft.SqlServer.Server -Version 1.0.0
<PackageReference Include="Microsoft.SqlServer.Server" Version="1.0.0" />
<PackageVersion Include="Microsoft.SqlServer.Server" Version="1.0.0" />
<PackageReference Include="Microsoft.SqlServer.Server" />
paket add Microsoft.SqlServer.Server --version 1.0.0
#r "nuget: Microsoft.SqlServer.Server, 1.0.0"
#:package Microsoft.SqlServer.Server@1.0.0
#addin nuget:?package=Microsoft.SqlServer.Server&version=1.0.0
#tool nuget:?package=Microsoft.SqlServer.Server&version=1.0.0
Microsoft.SqlServer.Server
Description
This is a helper library for Microsoft.Data.SqlClient, enabling cross-framework support for User-Defined Types (UDTs) in SQL Server.
The package provides the types and attributes needed to create SQL Server CLR user-defined types, user-defined aggregates, and user-defined functions that work seamlessly across .NET Framework and .NET Core/.NET.
Supportability
This package supports:
- .NET Framework 4.6+
- .NET Standard 2.0 (for .NET Core 2.0+ and .NET 5+)
Installation
Install the package via NuGet:
dotnet add package Microsoft.SqlServer.Server
Or via the Package Manager Console:
Install-Package Microsoft.SqlServer.Server
Available Types
This package provides the following types in the Microsoft.SqlServer.Server namespace:
| Type | Description |
|---|---|
IBinarySerialize |
Interface for custom binary serialization of UDTs |
InvalidUdtException |
Exception thrown when a UDT is invalid |
SqlFacetAttribute |
Specifies additional information about UDT properties |
SqlFunctionAttribute |
Marks a method as a SQL Server function |
SqlMethodAttribute |
Specifies method properties for UDT methods |
SqlUserDefinedAggregateAttribute |
Marks a class as a user-defined aggregate |
SqlUserDefinedTypeAttribute |
Marks a class as a user-defined type |
DataAccessKind |
Describes data access behavior for a function |
SystemDataAccessKind |
Describes system data access behavior |
Format |
Specifies the serialization format for UDTs |
Getting Started
Creating a User-Defined Type
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
[SqlUserDefinedType(Format.Native)]
public struct Point : INullable
{
private bool _isNull;
private double _x;
private double _y;
public bool IsNull => _isNull;
public static Point Null
{
get
{
var p = new Point();
p._isNull = true;
return p;
}
}
public double X
{
get => _x;
set => _x = value;
}
public double Y
{
get => _y;
set => _y = value;
}
public static Point Parse(SqlString s)
{
if (s.IsNull)
return Null;
var parts = s.Value.Split(',');
return new Point
{
X = double.Parse(parts[0]),
Y = double.Parse(parts[1])
};
}
public override string ToString() => _isNull ? "NULL" : $"{_x},{_y}";
}
Creating a User-Defined Aggregate
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
using System.IO;
[SqlUserDefinedAggregate(Format.UserDefined, MaxByteSize = 8000)]
public class Concatenate : IBinarySerialize
{
private StringBuilder _builder;
public void Init()
{
_builder = new StringBuilder();
}
public void Accumulate(SqlString value)
{
if (!value.IsNull)
{
if (_builder.Length > 0)
_builder.Append(",");
_builder.Append(value.Value);
}
}
public void Merge(Concatenate other)
{
if (other._builder.Length > 0)
{
if (_builder.Length > 0)
_builder.Append(",");
_builder.Append(other._builder);
}
}
public SqlString Terminate() => new SqlString(_builder.ToString());
public void Read(BinaryReader reader) => _builder = new StringBuilder(reader.ReadString());
public void Write(BinaryWriter writer) => writer.Write(_builder.ToString());
}
Documentation
- SQL Server CLR Integration
- CLR User-Defined Types
- CLR User-Defined Aggregates
- Microsoft.Data.SqlClient Documentation
Release Notes
Release notes are available at: https://go.microsoft.com/fwlink/?linkid=2185441
License
This package is licensed under the MIT License.
Related Packages
- Microsoft.Data.SqlClient - The main SqlClient driver
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Microsoft.SqlServer.Server:
| Repository | Stars |
|---|---|
|
microsoft/DacFx
DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
|
|
|
MyCaffe/MyCaffe
A complete deep learning platform written almost entirely in C# for Windows developers! Now you can write your own layers in C#!
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 6 | 3/12/2026 |